![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/175346/image.jpeg)
how to get the position of the pixel?
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Image Analyst
le 3 Août 2014
Modifié(e) : Image Analyst
le 3 Août 2014
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 commentaires
Plus de réponses (0)
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!