1 | initial version |
To quickly detect circles with very large diameter variation, you can use the radial symmetry transform (as they are radially symmetric) (Loy&Zelinsky 2002). It's not in OpenCV, but it's easy to implement.
The algorithm is the following:
2 | No.2 Revision |
To quickly detect circles with very large diameter variation, you can use the radial symmetry transform (as they are radially symmetric) (Loy&Zelinsky 2002). It's not in OpenCV, but it's easy to implement.
The algorithm is the following:
3 | No.3 Revision |
To quickly detect circles with very large diameter variation, you can use the radial symmetry transform (as they are radially symmetric) (Loy&Zelinsky 2002). It's not in OpenCV, but it's easy to implement.
The algorithm is the following:
Here is the result of the radial symmetry transform (the accumulator space) for the image above and a detection length of 60 pixels. The center of all the coins is clearly visible, for any radius.
4 | No.4 Revision |
To quickly detect circles with very large diameter variation, you can use the radial symmetry transform (as they are radially symmetric) (Loy&Zelinsky 2002). It's not in OpenCV, but it's easy to implement.
The algorithm is the following:
Here is the result of the radial symmetry transform (the accumulator space) for the image above and a detection length of 60 pixels. The center of all the coins is clearly visible, for any radius.
5 | No.5 Revision |
To quickly detect circles with very large diameter variation, you can use the radial symmetry transform (as they are radially symmetric) (Loy&Zelinsky 2002). This is a very robust and proven algorithm for circular object detection for any radius. It's not in part of OpenCV, but it's easy to implement.
The algorithm is the following:
Here is the result of the radial symmetry transform (the accumulator space) for the image above and a detection length of 60 pixels. The center of all the coins is clearly visible, for any radius.
6 | No.6 Revision |
To quickly detect circles with very large diameter variation, you can use the radial symmetry transform (as they are radially symmetric) (Loy&Zelinsky 2002). This is a very robust and proven algorithm for circular object detection for any radius. It's not part of OpenCV, but it's easy to implement.
The algorithm is the following:
Here is the result of the radial symmetry transform (the accumulator space) for the image above and a detection length of 60 pixels. The center of all the coins is clearly visible, for any radius.
Here is the C++ code for the proposed algorithm. It takes the X and Y gradients and the detection radius (ray
). minval
and maxval
are low and high thresholds for the gradient.
void RadSymTransform(InputArray gradx,InputArray grady,OutputArray result,int ray,double minval=0,double maxval=255)
{
Mat gxMat=gradx.getMat();
Mat gyMat=grady.getMat();
result.create(gradx.size(), CV_16UC1);
Mat resMat=result.getMat();
resMat=Mat::zeros(resMat.size(), resMat.type());
int x,y,i,H,W;
double tx,ty,gx,gy,ampl,max;
H=gxMat.rows;W=gxMat.cols;
for(y=0;y<H;y++)
for (x = 0; x < W; x++)
{
gx=gxMat.at<double>(y,x);
gy=gyMat.at<double>(y,x);
ampl=sqrt(gx*gx+gy*gy);
if((ampl>minval)&&(ampl<maxval)){
max=(abs(gx)>abs(gy)?abs(gx):abs(gy));
gx/=max;gy/=max;
tx=x-ray*gx;ty=y-ray*gy;
if(tx<0||tx>W||ty<0||ty>H)continue;
tx=x;ty=y;
for (i = 0; i < ray; ++i)
{
tx-=gx;ty-=gy;
resMat.at<ushort>((int)ty,(int)tx)++;
}
}
}
}