The program should detect circles and colour them in red. The symmetry method was suggested where I assume each pixel is a center of a circle and check the four points r (radius) distance from it. If they are the same, draw a circle. However in the code bellow I get way to many unnecessary circles
static boolean isCenterOfCircle(int row, int col, int r, BufferedImage image) {
//getPixels gets the color of the current pixel.
if(getPixel(row,col,image) == getPixel(row+r,col,image)
|| getPixel(row,col,image) == getPixel(row-r,col,image)
|| getPixel(row,col,image) == getPixel(row,col+r,image)
|| getPixel(row,col,image) == getPixel(row,col-r,image)){
return true;
}else{
return false;
}
}
You should check more than 4 points to detect the circle. What about 16 or more. Maybe depending on the radius. For bigger radius you should check more points.
Or search the web for circle detecting algorithms. There are other approaches than checking a few pixels.