I want to crop an image using its x,y coordiates using BufferedImage.getSubimage(x,y,width,height) function in java. But i only have bounding box of an image to crop some part of it.
How can i get x,y coordinates from bounding box using java? Is there any calculation available?
I am giving bounding box values (xMin,yMin,xMax,yMax)(0.46476197,0.46967554,0.8502463,0.67080903 )
I am multiplying bounding box values with image width and height respectively to get its pixel values.
int y1 = yMin * ImageHeight;
int x1 = xMin * ImageWidth;
int y2 = yMax * ImageHeight;
int x2 = xMax * ImageWidth;
And applied the values to below given formula
BufferedImage.getSubimage((int)x1, (int)y1, (x2-x1), (y2-y1));
Thanks gilbert for giving solution to get pixel values.