Home > Back-end >  Image recognition testing center position
Image recognition testing center position

Time:09-26

Given 4 there are three circular tablets of image, require detect the position of each pill (center) and the total number of pills in each image, if you can distinguish different kinds of tablets, and to detect the number of all kinds of tablets, the better,
In C

CodePudding user response:

Hough detection round
According to the equation of garden (x - a) * (x - a) + (y - b) * (y - b)=R * R, add parameter space to a, b, R 3 d space.
Commonly used hough transform calculation is too large, randomized hough transform, however, although a relatively small amount of calculation, but there is no higher accuracy. Now use
An improved method: to extract the edge image, and then the edge tracking, hough transform to detect the circle on the edge curve.

Double x=0.0, y=0.0, x0=0.0, y0=0.0, cc=0.0, the ss=0.0, temp1, temp2;
Int aa=0, bb=0, rr=0, saveaa=0, savebb=0, saverr=0, savexx0=0, saveyy0=0, saveQ=0;
Int pos=ptNumber/3;
Int I=0, off=0, k=0, iBaseFlag=100, jj=0;
Int tt=0, m=0, n=0;
Int firstBase=5;
Int secendBase=(2 * firstBase + 1);
Int aaBase=(R.r d.light + R.l eft)/2 - firstBase bbBase=(r. b ottom + R.t op)/2 - firstBase;
LONG minrr=0;
Minrr=(R.r d.light - R.l eft) & gt; (r. b ottom - R.t op)? (r. b ottom - R.t op) : (R.r d.light - R.l eft);
Int memsize=(int) (minrr firstBase) + 2 * * * secendBase secendBase;
BYTE * lpabr=new BYTE [memsize];
Memset (lpabr, 0, sizeof (BYTE) * memsize);
Int maxcount=1;


/* the local part of the hough transform to detect the circle curve segment */
For (k=0; K{
For (aa=(int) (R.l eft + R.r d.light)/2 - firstBase; Aa<=(int) (R.l eft + R.r d.light)/2 + firstBase; Aa++)
{
If (aa<0)
continue;
If (aa> ImageWidth)
break;
For (bb=(int) (R.t op + r. b ottom)/2 - firstBase; Bb<=(int) (R.t op + r. b ottom)/2 + firstBase; Bb++)
{
If (bb<0)
continue;
If (bb> ImageHeight)
break;
Temp1=(pt [k]. X - aa) * (pt [k]. X - aa) + (pt [k]. Y - bb) * (pt [k]. Y - bb);
Rr=(int) SQRT (temp1);
If (rr>=10 & amp; & Rr<=(int) (minrr/2) + firstBase)
SecendBase lpabr [rr * * secendBase + (aa - aaBase) * secendBase + (bb - bbBase)] + +;
}

}

}

For (rr=10; Rr<=(int) (minrr/2) + firstBase; Rr++)
For (aa=(int) (R.l eft + R.r d.light)/2 - firstBase; Aa<=(int) (R.l eft + R.r d.light)/2 + firstBase; Aa++)
{
If (aa<0)
continue;
If (aa> ImageWidth)
break;
For (bb=(int) (R.t op + r. b ottom)/2 - firstBase; Bb<=(int) (R.t op + r. b ottom)/2 + firstBase; Bb++)
{
If (bb<0)
continue;
If (bb> ImageHeight)
break;
If (maxcount{
SecendBase maxcount=lpabr [rr * * secendBase + (aa - aaBase) * secendBase + (bb - bbBase)];
Saverr=rr.
Saveaa=aa;
Savebb=bb;
}
}
}
If (maxcount>
=4){
//records center, half the
Saverr=rr.
Saveaa=aa;
Savebb=bb;


}

CodePudding user response:

Don't
Let me guess

The first kind of
Find out the difference area (pixels) than the original figure

The second
Directly compare the original figure
  • Related