1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
for(int radius = 10; radius<75; radius++)
{
// Loop through each pixel
for(int x=0;x<img->width;x++)
{
for(int y=0;y<img->height;y++)
{
// Check if the current pixel is an edge
int value = cvGetReal2D(edges, y, x);
if(value==0) continue;
// If it is an edge, generate its circle in the parameter space
for(int theta=0;theta<360;theta++)
{
int a = x + radius*cos(theta*3.1412/180);
int b = y + radius*sin(theta*3.1412/180);
// Just in case
if(a<0 || a>=img->width || b<0 || b>=img->height) continue;
value = cvGetReal2D(imgHough, b, a);
cvSetReal2D(imgHough, b, a, value+1);
}
}
} |
Partager