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
2015년 8월 28일
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
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
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
2015년 9월 4일
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
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
2015년 9월 7일
You were obviously right, good guessing!
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
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 Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
