Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 447
Milad R Avatar asked Jul 26 '12 21:07

Milad R


People also ask

How does cv2 resize work?

According to the API documentation of cv2. resize, your 640x480 matrix is being interpolated from whatever numbers are available in the data matrix you passed in. Unless you need your original 80x60 data "blown up" to some specific format, you should be able to skip this line/step without loss of information.


1 Answers

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.

like image 127
Mohammad Avatar answered Sep 22 '22 21:09

Mohammad