How to resize an image to a specific size in OpenCV?

Milad R picture Milad R · Jul 26, 2012 · Viewed 153k times · Source
IplImage* img = cvLoadImage("something.jpg");
IplImage* src = cvLoadImage("src.jpg");
cvSub(src, img, img);

But the size of the source image is different from img.

Is there any opencv function to resize it to the img size?

Answer

Mohammad picture Mohammad · Jul 27, 2012

You can use cvResize. Or better use c++ interface (eg cv::Mat instead of IplImage and cv::imread instead of cvLoadImage) and then use cv::resize which handles memory allocation and deallocation itself.