I have a 3 dimensional matrix (3rd dimension represents multiple copies of an M x N
grayscale image).
I'm taking the max value of each pixel across the images, giving me a max_val
and max_ix
matrix (2x2).
I want to reference the original test
matrix by the max_ix
values.
Example: my_max_val = test(max_ix,:)
should equal:
5 1
1 1
Obviously I can just use max_val
in this simplified example, but not in the real use case. I'm altering max_ix
, so I need to reference the original 3-dimensional matrix by the new index values I create (not depicted in this simplified example).
>> test
test(:,:,1) =
1 1
1 1
test(:,:,2) =
1 1
1 1
test(:,:,3) =
5 1
1 1
test(:,:,4) =
1 1
1 1
>> [max_val, max_ix] = max(test, [], 3)
max_val =
5 1
1 1
max_ix =
3 1
1 1
How do I recreate max_val
just from test
and max_ix
?