how to find the lowest pixel in a 3d matrix?
Show older comments
hello, I have 3D matrix with ones and zeroes. I need to know the index of the lowest and highest pixel with 1 value. lets say the Z axis is height, than I need to know the min/max height of the pixels with the value 1.
thank you!
Accepted Answer
More Answers (1)
Andrei Bobrov
on 4 Jun 2013
A = rand(15,5,5) < .3; % your data
s = size(A);
B = reshape(A,s(1),[]);
[ii jj] = find(B);
maxl = ii == max(ii);
[i1 j1] = ind2sub(s(2:3),jj(maxl));
maxidx = [ii(maxl),i1,j1];
minl = ii == min(ii);
[i2 j2] = ind2sub(s(2:3),jj(minl));
minidx = [ii(minl),i2,j2]
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!