Can you give some simple code? Beginners sorry
CodePudding user response:
First of all, I think you real images should do without you this picture is so clear, so the most important is how to identify the point, because there is no actual images, can't give you what algorithms such as dongdongBut if as you draw this figure, is obviously the color value judgement of
As for the logo position, where all know a little bit bad mark how much
CodePudding user response:
If it's so clear, the white is a connected, then statistical number, completed,CodePudding user response:
If you really like your pictures, only black and white two colors, and each circle is a closed the processing is simple.Find a white pixel points first, and then the circle filled with ExtFloodFill black is processed the
Then like just dealing with the next point, it is ok to.
If not so ideal result, it is expected to be wait for these specialized with opencv image processing library to do.
CodePudding user response:
Sorry xiaodi bucai I currently can be respectively connected to find a white dot area!! But I hope can be identified in each white point 1.2.3.4.5? Is how to mark, please?The following is my current code
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
#include
# pragma hdrstop
# include "Unit1. H"
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
# pragma package (smart_init)
# pragma resource "*. DFM
"TForm1 * Form1;
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
__fastcall TForm1: : TForm1 (TComponent * Owner)
: TForm (the Owner)
{
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
int count=0;
Int the Connect (Graphics: : TBitmap * BMP, int x, int y)
{
count++;
BMP - & gt; Canvas - & gt; Pixels [x] [y]=clBlack;
//?? (y, x + 1)
If (BMP - & gt; Canvas - & gt; Pixels [x + 1] [y]==clWhite)
{
Connect (BMP, x + 1, y);
}
//?? (x + 1, y - 1)
If (BMP - & gt; Canvas - & gt; Pixels [x + 1] [1] y==clWhite)
{
The Connect (BMP, x + 1, y - 1);
}
//?? (x + 1, y + 1)
If (BMP - & gt; Canvas - & gt; Pixels [x] [1] y==clWhite)
{
The Connect (BMP, x, y - 1);
}
//?? (x, y - 1)
If (BMP - & gt; Canvas - & gt; Pixels [1] x [1] y==clWhite)
{
The Connect (BMP, 1 x, y - 1);
}
//?? (x, y - 1)
If (BMP - & gt; Canvas - & gt; Pixels [1] x [y]==clWhite)
{
Connect (BMP, 1 x, y);
}
//?? (x, y)
If (BMP - & gt; Canvas - & gt; Pixels [1] x/y + 1==clWhite)
{
The Connect (BMP, 1 x, y + 1);
}
//?? (x, y - 1)
If (BMP - & gt; Canvas - & gt; Pixels [x] [y + 1]==clWhite)
{
The Connect (BMP, x, y + 1);
}
//?? (y, x + 1)
If (BMP - & gt; Canvas - & gt; Pixels [x + 1] [y + 1)==clWhite)
{
The Connect (BMP, x + 1, y + 1);
}
//?? (x, y + 1)
If (BMP - & gt; Canvas - & gt; Pixels [x + 1] [y]==clWhite)
{
Connect (BMP, x + 1, y);
}
Return (count);
}
Void __fastcall TForm1: : Button1Click (TObject * Sender)
{
Int j;
Int c=0;
Graphics: : TBitmap * BMP=new Graphics: : TBitmap ();
Byte * PTR=NULL;
BMP - & gt; The Assign (Image1 - & gt; Picture - & gt; Bitmap);;
For (int y=0; Y & lt; BMP - & gt; Height; Y++)
{
PTR=(Byte *) BMP - & gt; ScanLine [y];
For (int x=0; X & lt; BMP - & gt; Width; X++)
{
If (PTR [x * 3]==255)
{
Cx=Connect int (BMP, x, y);
Memo1 - & gt; Lines - & gt; Add (cx);
count=0;//? 0?
If (cx>=150 & amp; & Cx
=500)C +=1;
//break;
}
}
}
ShowMessage (c);
The delete BMP.
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --