Ask Your Question

Revision history [back]

Compute the distance of each point from the center. If it is less than radius, the point is inside the circle. Here is the code:

for ( int r = 0; r < image.rows; r++ )
    for ( int c = 0; c < image.cols; c++ )
    {
        double dist = sqrt ( ( c - center.x ) * ( c - center.x ) + ( r - center.y ) * ( r  - center.y ));
        if ( dist < radius )
            // Point is inside circle
        else
            // Point is outside circle
    }