我有以下圖片:如何檢測二值圖像RGB中的圓?
https://www.upsieutoc.com/images/2014/10/18/binkq27dd30.png
我想在我的圖像,算多少圈。我的圖像是nxn 8位二進制圖像,不是0和1. 那麼,我該怎麼辦? 謝謝您的閱讀!
我有以下圖片:如何檢測二值圖像RGB中的圓?
https://www.upsieutoc.com/images/2014/10/18/binkq27dd30.png
我想在我的圖像,算多少圈。我的圖像是nxn 8位二進制圖像,不是0和1. 那麼,我該怎麼辦? 謝謝您的閱讀!
一個減少的版本:http://www.codeproject.com/Articles/36378/Optical-Mark-Recognition-with-DotImage
//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;
}
}
然後通過boolen數組迭代,如果你有一排三個或四個1的上方和下方,如看到:
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
}
}
注意:你應該檢查相同的嵌套循環中的粒子。我只填充了一個多維布爾數組,以便您可以看到這兩個邏輯。
謝謝你:D !!!! – 2014-10-18 12:03:40
我看到0個圈子。非常有顆粒感。這將是一個超級PITA,即使對於一個具有明確定義的圓的人來說,這樣的圖像也是如此。 – 2014-10-18 03:21:34
從你的形象看,你需要光學標記識別(OMR)。一種可能性是http://www.codeproject.com/Articles/36378/Optical-Mark-Recognition-with-DotImage – 2014-10-18 03:26:05
謝謝你:D !!!! – 2014-10-18 12:01:47