I have a Jpeg image with a "seeming" uniform background and an actual object in it. I want to crop the image to extract only the object. I started with following code where I am trying to find the (x,y) on left side to start cropping.
I found out that bottom left corner of the image has (0,0) coordinates. I am looping through and trying to find out the exact point where the color changes.
The problem is during first iteration itself : when x=0 and y is incrementing, though there is no change in color it is giving different RGB values for few pixels.(like pixel 240 , 241, 242)
BufferedImage bf =ImageIO.read.file(imagePath);
for(int x= 0;x<bf.getWidth();x++)
{
for(int y=0; j<bf.getHeight();y++)
{
int color = bf.RGB(x,y);
int adjacentColor = bf.(x,y+1);
if(color !=adjacentColor)
{
LeftBoundaryPixels[count]=y;
count++;
break;
}
}
}