I've certain data set of images which has annotations for objects in that image. Annotations as in [xmin, xmax, ymin, ymax]
for the object in the image. How do I transform these coordinates to their new values when I resize the image while maintaining the aspect ratio ?
If you are simply resizing, use resize. For example:
using namespace cv;
Mat img;
img = imread("image.jpg", CV_LOAD_IMAGE_COLOR);
Mat dst;
resize(img, dst, Size(xmax-xmin,ymax-ymin));
If you are extracting sub image, use Rect. For example:
using namespace cv;
Mat original_img;
Rect roi;
roi.x = xmin;
roi.y = ymin;
roi.width = xmax-xmin;
roi.height = ymax-ymin;
Mat subimage = original_img(roi);
If you are trying to find out the coordinates(xmin,xmax,ymin,ymax) after resize,
multiply them by the factor of the resize.
For example, if the resize is by the factor of 0.5,
the coordinates(xmin,xmax,ymin,ymax) are now (xmin*0.5,xmax*0.5,ymin*0.5,ymax*0.5).