Ask Your Question

pnus's profile - activity

2019-09-23 13:19:40 -0600 received badge  Notable Question (source)
2018-12-06 06:22:43 -0600 received badge  Popular Question (source)
2016-05-13 00:39:09 -0600 asked a question OpenCV resize quality

I am trying to resize a set of images using OpenCV. The resolution is correct, but the quality of the image degrades. However, if I do a manual resize through Apple Preview, the image quality is not affected. I am making all of these images smaller, rather than blowing them up. Here are two images comparing the quality. Please note the jagged spokes and jagged top tube of the bike:

Bad Resize

Bad resize

* Good Resize using Apple Preview* Good resize using Apple Preview

Here is my code:

cv::Mat srcimg = cv::imread(src_filepath);
cv::Mat destimg = cv::imread(lowres_path);
cv::Size img_size = srcimg.size();
int img_width = img_size.width;
int img_height = img_size.height;
double percentage = 1000.0/(img_width);
double new_height = img_height * percentage;
cv::Size new_size = cv::Size(1000.0, new_height);
cv::resize(srcimg, destimg, new_size,0,0,CV_INTER_LANCZOS4);
cv::imwrite(lowres_path, destimg);

I've messed with the the interpolation but that seems to have no effect on the image.