finding coordinates of specific pixel using pixel value ?
Mostrar comentarios más antiguos
how to get (x,y)coordinates of an image in matlab using pixel value..for example if pixel value is 250 then find the x,y coordinates of all pixel having value 250

Respuesta aceptada
Más respuestas (1)
Bjorn Gustavsson
el 28 de Ag. de 2015
Try:
help find
Then you should see that
[i1,i2] = find(I==250);
Or if your image is in some double precision format when you cant rely on finding exact equality of pixel values:
[i1,i2] = find(round(scalefactorofyourchoise*(I-250)==0);
HTH
9 comentarios
Walter Roberson
el 29 de Ag. de 2015
No, the value of green is (0,255,0)
find(A(:,:,1)==0&A(:,:,2)==255&A(:,:,3)==0)
Image Analyst
el 29 de Ag. de 2015
Shouldn't you have the coordinates already? I mean, didn't you plot the green dots yourself?
Also be aware that find() returns (row, column) which is (y, x) NOT (x, y).
Dani
el 4 de Sept. de 2015
Bjorn Gustavsson
el 5 de Sept. de 2015
Well, you only need to use Walters comparison to get them:
[i1,i2] = find(A(:,:,1)<=10&A(:,:,2)>=245&A(:,:,3)<=10);
The only thing I changed here was to find all points where the read and blue layers of the image have values lower than 10, and the green layer are above 245. This would possibly give you slightly larger number of identified points. Only you can try this and see what points you'll actually want.
HTH
Image Analyst
el 5 de Sept. de 2015
I think what she wants is not to find the green dots in an image annotated in Photoshop and then saved, but an algorithm to find the eyes and mouth from the original, un-annotated image. Is that correct?
Bjorn Gustavsson
el 7 de Sept. de 2015
You were obviously right, good guessing!
Renuka
el 15 de Sept. de 2017
Editada: Walter Roberson
el 15 de Sept. de 2017
After doing the above:
[i1,i2] = find(I==250);
How do I get each of the (i1, i2) pair?
I need to set some value for each coordinate obtained from the above finding...
Please reply ASAP.
Walter Roberson
el 15 de Sept. de 2017
The K'th pair is I(i1(K), i2(K))
If you need to get all of them at once then easiest is
idx = find(I==250);
I(idx)
using only one index instead of a pair.
If you need the pair of indices for some reason then
[i1,i2] = find(I==250);
I( sub2ind(size(I), i1, i2) )
Categorías
Más información sobre Read, Write, and Modify Image en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
