Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Resize image without loosing image quality in c++ or opencv

Tags:

c++

image

opencv

  • I am working on one project and for that i need to scale up image.

  • I have tried re size function of OpenCv library for re sizing.But image quality is decreased.

  • Suppose i have image of 136x136 size and i want to re size it to 209x209 with same quality.How can i do it?

like image 804
Sagar Patel Avatar asked Oct 29 '25 15:10

Sagar Patel


1 Answers

As suggested in the comments, there is no way to increase the size of your image and generate new information between the pixels. All resizing methods involve some kind of interpolation between the original information.

If you look at the OpenCV documentation for the resize function you will see these options:

  • INTER_NEAREST - a nearest-neighbor interpolation
  • INTER_LINEAR - a bilinear interpolation (used by default)
  • INTER_AREA - resampling using pixel area relation. It may be a preferred method for image decimation, as it gives moire’-free results. But when the image is zoomed, it is similar to the INTER_NEAREST method.
  • INTER_CUBIC - a bicubic interpolation over 4x4 pixel neighborhood
  • INTER_LANCZOS4 - a Lanczos interpolation over 8x8 pixel neighborhood

You may find that INTER_CUBIC or INTER_LANCZOS4 produce an image with higher "quality".

like image 112
Brian Lynch Avatar answered Oct 31 '25 06:10

Brian Lynch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!