finding coordinates of specific pixel using pixel value ?

26 vues (au cours des 30 derniers jours)
Dani
Dani le 27 Août 2015
Commenté : Walter Roberson le 15 Sep 2017
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

Réponse acceptée

Image Analyst
Image Analyst le 5 Sep 2015

Plus de réponses (1)

Bjorn Gustavsson
Bjorn Gustavsson le 28 Août 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 commentaires
Renuka
Renuka le 15 Sep 2017
Modifié(e) : Walter Roberson le 15 Sep 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
Walter Roberson le 15 Sep 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) )

Connectez-vous pour commenter.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by