Finding particular R, G, B value by comparing with threshold and fetching its corresponding pixel locations from table
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
meenu v
am 19 Mai 2018
Kommentiert: meenu v
am 29 Mai 2018
I have a 20*3 rgbvalues matrix of an image
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/190683/image.png)
and given below table cx and cy are its corresponding pixel locations
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/190684/image.png)
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?
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 19 Mai 2018
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 Kommentare
Image Analyst
am 27 Mai 2018
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.
Weitere Antworten (2)
Jan
am 19 Mai 2018
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.
0 Kommentare
meenu v
am 28 Mai 2018
Bearbeitet: meenu v
am 28 Mai 2018
2 Kommentare
Image Analyst
am 28 Mai 2018
Bearbeitet: Image Analyst
am 28 Mai 2018
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.
Siehe auch
Kategorien
Mehr zu Convert Image Type finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!