フィルターのクリア

Finding particular R, G, B value by comparing with threshold and fetching its corresponding pixel locations from table

3 ビュー (過去 30 日間)
I have a 20*3 rgbvalues matrix of an image
and given below table cx and cy are its corresponding pixel locations
and now i want to check in the rgbvalues table which satisfying the following condition,
((R>=0 && R<=100) && (G>=0 && G<=100) &&(B>=0 && B<=100)) and the corresponding cx and cy pixel location values. can anybody help me?

採用された回答

Image Analyst
Image Analyst 2018 年 5 月 19 日
Try this:
mask = (R>=0 & R<=100) & (G>=0 & G<=100) & (B>=0 & B<=100);
cxInMask = cx(mask);
cyInMask = cy(mask);
Take special note that I am using only single ampersands, not double ones because I want to do operations on a logical vector.
For your data, like Jan said, both will be empty since no row satisfies your criteria.
  3 件のコメント
Image Analyst
Image Analyst 2018 年 5 月 27 日
No, using a single ampersand will create a binary image - a mask image.
"How can be make it possible?" I already showed you. Just do what I said. Don't change it back to what you said which will make it not work again. Make adjustments to the values if you want but don't change the ampersands to double ampersands.

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

その他の回答 (2 件)

Jan
Jan 2018 年 5 月 19 日
None of the colors in the table satisfies B <= 100. What ever the relation between the two tables is and whatever "corresponding cx and cy pixel location" means, while no element of B is matching, the condition is false in every case.
This solution seems to be trivial. Therefore I guess, you meant something else. Then please explain it again.

meenu v
meenu v 2018 年 5 月 28 日
編集済み: meenu v 2018 年 5 月 28 日
Some part of the code is given
pq =impixel(Original_Img(:,:,1:3), cxInMask,cyInMask);
R=pq(:,1);
G=pq (:,2);
B=pq (:,3);
if ((x (1) > 58 && x (1) < 200) && (y(1) > 401 && y(1) < 650))
if ((R>=0 && R<=250)&&(G>=0 && G<=50)&&(B>=0 && B<=255))
disp ('The content is very low in this region.');
elseif ((R>=0 && R<=190)&&(G>=0 && G<=90)&&(B>=250 && B<=255))
disp ('The content is high in this region.');
end
end
R, G, B vector obtained will be like the one shown in above question. The values will change in every exceution .
Running the code produces an error like,
  • _Operands to the and && operators must be convertible to logical scalar values.
Error in Untitled (line 25) If ((R>=0 && R<=250)&&(G>=0 && G<=1)&&(B>=0 && B<=255))
_ * How to resolve this error?
  2 件のコメント
Image Analyst
Image Analyst 2018 年 5 月 28 日
編集済み: Image Analyst 2018 年 5 月 28 日
If you'd look in the workspace, you'd see that you never defined an x and y. Plus R, G, and B are most likely full images, not single values so you should be using single ampersands like I've told you already, or if you want the R, G, and B at a single point then you should index them or use the pq variable you created.
meenu v
meenu v 2018 年 5 月 29 日
this is not what i meant to ask. i will start a new question for that. Thank u....

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

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by