C# 如何在二值图像RGB中检测圆?
我有以下图像: 我想数一数我的图像中有多少个圆圈。我的图像是nxn 8位二进制图像,不是0和1。 那么,我能做什么? 谢谢你的阅读 以下内容的精简版本:C# 如何在二值图像RGB中检测圆?,c#,image-processing,C#,Image Processing,我有以下图像: 我想数一数我的图像中有多少个圆圈。我的图像是nxn 8位二进制图像,不是0和1。 那么,我能做什么? 谢谢你的阅读 以下内容的精简版本: 注意:您应该检查同一嵌套循环中的循环。我只填充了一个多维布尔数组,这样您就可以看到这两个逻辑。我看到了0个圆。非常粗糙。这将是一个超级皮塔,即使对于一个人来说,用这样的图像定义一个很好的圆。从你的图像的外观来看,你需要光学标记识别(OMR)。一种可能是 //Create a Bitmap object from an image file.
注意:您应该检查同一嵌套循环中的循环。我只填充了一个多维布尔数组,这样您就可以看到这两个逻辑。我看到了0个圆。非常粗糙。这将是一个超级皮塔,即使对于一个人来说,用这样的图像定义一个很好的圆。从你的图像的外观来看,你需要光学标记识别(OMR)。一种可能是
//Create a Bitmap object from an image file.
Bitmap myBitmap = new Bitmap("Answers.jpg");
//Check the pixels in the Bitmap for the circles:
for (int i = 0; i < myBitmap.Width;i++)
{
for (int j = 0; j < myBitmap.Height;j++)
{
Color pixelColor = myBitmap.GetPixel(i, j);
//Translate pixel to a 1 or 0 depending on if the pixel is black or white
//This next line is psuedo code:
boolArray[i][j] = pixelColour.R < 128 && pixelColour.G < 128 && pixelColour.B < 128;
}
}
if (boolArray[i][j] && boolArray[i + 1][j] && boolArray[i + 2][j])
{
if (boolArray[i][j + 1] && boolArray[i][j + 2] && boolArray[i][j + 3])
{
//found an answer marked as a filled in circle
}
}