How to Resize image without loosing image quality in c++ or opencv
11,651
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".
Comments
-
Sagar Patel almost 2 years
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?
-
Micka over 8 yearsin special cases (e.g. pure black and pure white image), inter_nearest might be best because it wont introduce new colors (e.g. grayscale levels) to the image. But object borders will look more pixelized/blocklike.