graphics - Find a particular color in a 2D image -
graphics - Find a particular color in a 2D image -
what algorithms observe or find particular color (rgb) in image. detection purposely used marker find position of particular color used.
if know color can it:
c++
glm::vec3 targetcolor(1.0f,0,0);//(red,blue,green) float accepted_color_distance = 0.1f; /*how much must colors alike? distance 0 means colors must equal, there numeric precission problems. utilize 0.0001f or instead of 0.*/ bool markersfound[image.rows][image.cols]; //true means pixel y,x markers for(unsigned int = 0; < image.rows; a++) //init markersfound false { for(unsigned int b = 0; b < image.cols; b++) { bool markersfound[a][b] = false; } } for(unsigned int = 0; < image.rows; a++) { for(unsigned int b = 0; b < image.rows; b++) { glm::vec3 currentcolor = image.at(a,b); float color_distance = glm::distance(currentcolor, targetcolor); if(color_distance < accepted_color_distance) //if marker found save { bool markersfound[a][b] = true; } } }
image-processing graphics computer-vision
Comments
Post a Comment