finding coordinates of specific pixel using pixel value ?

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

その他の回答 (1 件)

Bjorn Gustavsson
Bjorn Gustavsson 2015 年 8 月 28 日

1 投票

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 件のコメント

Dani
Dani 2015 年 8 月 29 日
編集済み: Dani 2015 年 8 月 29 日
image is in .png that means using RGB . i am trying to find xy coordinates of green points. the value of green is exactly 255
Walter Roberson
Walter Roberson 2015 年 8 月 29 日
No, the value of green is (0,255,0)
find(A(:,:,1)==0&A(:,:,2)==255&A(:,:,3)==0)
Image Analyst
Image Analyst 2015 年 8 月 29 日
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
Dani 2015 年 9 月 4 日
sorry for late....i plot the green dots by hand in photo shop,,,,I want to use these points in matlab,,,but i don't have these in matlab.
Bjorn Gustavsson
Bjorn Gustavsson 2015 年 9 月 5 日
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
Image Analyst 2015 年 9 月 5 日
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
Bjorn Gustavsson 2015 年 9 月 7 日
You were obviously right, good guessing!
Renuka
Renuka 2017 年 9 月 15 日
編集済み: Walter Roberson 2017 年 9 月 15 日
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 2017 年 9 月 15 日
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) )

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeRead, Write, and Modify Image についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by