MATLAB: How to find the lowest pixel in a 3d matrix

matrix

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!

Best Answer

Assuming your 3D array is A
map=any(reshape(A,[],size(A,3)),1);
minheight =find(map,1);
maxheight=find(map,1,'last');
Related Question