Image processing 在二维图像中查找特定颜色
有哪些算法可以检测或找到图像中的特定颜色RGB。检测将被故意用作标记,以找到特定颜色的位置,然后使用该位置 如果你知道它的颜色,你可以直接寻找: C++Image processing 在二维图像中查找特定颜色,image-processing,graphics,computer-vision,Image Processing,Graphics,Computer Vision,有哪些算法可以检测或找到图像中的特定颜色RGB。检测将被故意用作标记,以找到特定颜色的位置,然后使用该位置 如果你知道它的颜色,你可以直接寻找: C++ 不呢?你可以自己翻译。你还应该更新你帖子中的标签,使其显示C。这样人们就不会在你不喜欢的语言上浪费时间。现在你输入的是:家庭作业。新的社区网站。 glm::vec3 targetColor(1.0f,0,0);//(red,blue,green) float accepted_color_distance = 0.1f; /*how much
不呢?你可以自己翻译。你还应该更新你帖子中的标签,使其显示C。这样人们就不会在你不喜欢的语言上浪费时间。现在你输入的是:家庭作业。新的社区网站。
glm::vec3 targetColor(1.0f,0,0);//(red,blue,green)
float accepted_color_distance = 0.1f;
/*how much must look the colors alike? distance 0 means the colors must be equal,
but there are numeric precission problems. Use 0.0001f or
something instead of 0.*/
bool markersFound[image.rows][image.cols]; //true means pixel y,x is a markers
for(unsigned int a = 0; a < image.rows; a++) //init markersFound with false
{
for(unsigned int b = 0; b < image.cols; b++)
{
bool markersFound[a][b] = false;
}
}
for(unsigned int a = 0; a < 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 a marker is found save it
{
bool markersFound[a][b] = true;
}
}
}