How to find closest color to R,G, or B?
in
Programming Questions
•
1 years ago
Hey guys,
I'm using a webcam to find the closest color of red, green or blue in an area of the capture image. The code will be used to check the color of a solid rectangle that will either be red, green or blue. If the color is red, then the value then be converted to a string as "red", etc. I will be doing this for four pixel areas, so I am looking for a way to do this without a ton of 'if' statements.
I have played around with the get() and red(),green(),blue() functions but am having trouble finding an efficient way to do this.
Any help would be greatly appreciated!
-Max
I'm using a webcam to find the closest color of red, green or blue in an area of the capture image. The code will be used to check the color of a solid rectangle that will either be red, green or blue. If the color is red, then the value then be converted to a string as "red", etc. I will be doing this for four pixel areas, so I am looking for a way to do this without a ton of 'if' statements.
I have played around with the get() and red(),green(),blue() functions but am having trouble finding an efficient way to do this.
Any help would be greatly appreciated!
-Max
1