Ask Your Question
0

Comparison betweens resize/interpolation algorithms

asked 2017-05-12 14:07:23 -0500

Jamesac gravatar image

Hello, I'm trying to evaluate nearest, bilinear and bicubic interpolation algorithms from the resize function but all my images are exactly the same.

Can anyone help me?

Mat img; 
Mat img2;

img = imread("face2.png", IMREAD_UNCHANGED);

Size size(720,1080);

vector<int> com_param;
com_param.push_back(CV_IMWRITE_JPEG_QUALITY);
com_param.push_back(9);
cv::resize(img, img2, size, cv::INTER_NEAREST);
imwrite("nearest.jpg",img2,com_param);
cv::resize(img, img2, size, cv::INTER_NEAREST);
imwrite("bilinear.jpg",img2,com_param);
cv::resize(img, img2, size, cv::INTER_NEAREST);
imwrite("cubic.jpg",img2,com_param);
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2017-05-12 14:14:55 -0500

LBerger gravatar image

Use flags! and don't save in a compress format

cv::resize(img, img2, size, cv::INTER_NEAREST);
imwrite("nearest.png",img2);
cv::resize(img, img2, size, cv::INTER_LINEAR );
imwrite("bilinear.png",img2);
cv::resize(img, img2, size, INTER_CUBIC );
imwrite("cubic.png",img2);
edit flag offensive delete link more

Comments

Thank you for the answer.

Done it already but no changes. Which flags do you mean?

Jamesac gravatar imageJamesac ( 2017-05-22 12:58:53 -0500 )edit

to see a difference orignal size must be smaller tahn destination size

LBerger gravatar imageLBerger ( 2017-05-22 14:12:08 -0500 )edit
1

Thank you for your help. I figure out that I wasn't using factor size as a parameter.

It is working now.

Jamesac gravatar imageJamesac ( 2017-06-12 11:23:11 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-05-12 14:07:23 -0500

Seen: 446 times

Last updated: May 12 '17