Not losing the quality of pictures saved with cv2.imwrite()

坚强是说给别人听的谎言 提交于 2020-01-17 04:15:09

问题


I am wondering seriously about the effects of cv2.imwrite() function of OpenCV.

I noticed that when I read pictures with cv2.imread() and save them again with cv2.imwrite() function, their quality is not the same any more for the human eyes.

I ask you how can I keep the quality of the image the same as the original after saving it using cv2.imwrite() function.

I ask this question because I have really a serious issue in a larger program and when I checked the quality of the pictures saved by this function, I guesses that my problem comes certainly from this function.

For example, I draw using the mouse movements small red (Red=255) squares on picture . When I save the picture and count the number of pixels that have Red color equal to 255 I get very few of them only even if I draw a lot of them in pure red color. But when I check the image by my eyes, I notice the red pixels I drawed are not correctly saved in the correct red color I chosed (255).

Any one does know how to resolve this problem ? I mean to save the pictures using OpenCV without degrading its quality.


回答1:


JPEG is a lossy format, you need to save your images as PNG as it is a lossless format.



来源:https://stackoverflow.com/questions/28940711/not-losing-the-quality-of-pictures-saved-with-cv2-imwrite

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