how can we get coordinates of non zero pixel in 3D image
4 次查看(过去 30 天)
显示 更早的评论
I have a stack of 249 images (image of the skeleton of the aorta) it appears like points in some slices and like lines in another slices. I want to get for each slice the coordinates of the non zero value in the image (my images are binary). I tried the command Find but it gives me just the coordinates and i don't know at which slice it corresponds.
0 个评论
回答(2 个)
KSSV
2017-2-1
编辑:KSSV
2017-2-1
find gives you row and col position along with the value you asked to seek. You can run a loop on each matrix and use find as
[row,col,v] = find(I(:,:,1)~=0)
Or alternatively you can try find on 3D matrix using:
[r,c,v] = ind2sub(size(I),find(I ~= 0));
Note that the above command is taken from the link: https://in.mathworks.com/matlabcentral/answers/789-using-find-in-a-3d-matrix-in-matlab
3 个评论
Image Analyst
2018-12-17
Of WHAT point? You have the coordinates of all the points. If you want one certain special point, you're going to have to identify it somehow so we know which one it is.
Sayan Bhattacharya
2018-12-18
编辑:Sayan Bhattacharya
2018-12-18
Image Analyst,
Like in the following figure, let's say its size is 100x100 that's rows & columns.
If we are moving lets say from 1st row to the last row in a loop can you please help me get the code for identifying the co-ordinates of that point where there is 1st non zero pixel encountered?![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/199339/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/199339/image.jpeg)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!