![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/175346/image.jpeg)
how to get the position of the pixel?
6 ビュー (過去 30 日間)
古いコメントを表示
for example I have an 256x256 image,called A.
any method to get every pixel position?
actually, I try to find the longest line on 3D the image in binary.
So I want to write a loop to calculate distance between every pixel in white and find the max one .
Thanks
0 件のコメント
採用された回答
Image Analyst
2014 年 8 月 3 日
編集済み: Image Analyst
2014 年 8 月 3 日
Every pixel position is given by meshgrid
[rows, columns, numberOfColorChannels] = size(yourImage);
[x, y] = meshgrid(1:rows, 1:columns);
You most likely don't need that. If you want to find the two points in the image that are fartest apart, you need to use bwboundaries to get a list of boundary coordinates, then use a nested for loop to calculate which pair of points have the greatest distance between them. This is exactly what my attached demo (below the image) does.
See the red line below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/175346/image.jpeg)
That red line goes between the farthest points in the binary image. The magenta line is the line at the midpoint that is perpendicular to it.
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!