How to Reduce the Resolution of an Image in OpenCV?

北城以北 提交于 2021-02-07 07:53:45

问题


So, I have an image from a digital scanner, its resolution is 26 Megapixel. I want to reduce the resolution of the image to 5 Megapixel.

Is it possible to reduce the resolution of an image without damaging the contents?

If yes, how to reduce it in OpenCV implementation?

Any help would be greatly appreciated. Thankyou


回答1:


You can use cv2::resize()

resize(src, dst, Size(), factor, factor, interpolation);

here, interpolation can be selected as cv::INTER_LANCZOS4 to obtain best interpolation results.

factor is the sampling ratio and in order to transform from 26mp to 5mp you may need it to be 2.28

Downsampling always introduces some information and detail loss.




回答2:


Reducing the resolution of the image is the very definition of damaging the content. Lossless image compression does not reduce the resolution of the image. That said 5 megapixels is still a very high resolution and more then most applications should require. The exceptions might be scientific and medical applications. I would simply ensure that you are preserving the original until you know you can work with the result and choose your image compression method carefully to reduce artifacts.



来源:https://stackoverflow.com/questions/17343469/how-to-reduce-the-resolution-of-an-image-in-opencv

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!