不损失使用cv2.imwrite()保存的图片的质量 [英] Not losing the quality of pictures saved with cv2.imwrite()
问题描述
我很想知道OpenCV的 cv2.imwrite()
函数的作用。
I am wondering seriously about the effects of cv2.imwrite()
function of OpenCV.
我注意到当我使用 cv2.imread()
阅读图片并使用 cv2.imwrite()
函数再次保存它们时,
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.
我问您在使用<$保存图像后,如何保持图像的质量与原始图像相同? c $ c> cv2.imwrite()函数。
我问这个问题是因为在较大的程序中以及在什么时候出现严重问题我检查了此功能保存的图片的质量,我想我的问题肯定是由该功能引起的。
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.
例如,我使用鼠标移动小红色绘制(图片上的红色= 255)正方形。当我保存图片并计算具有等于255的红色的像素数时,即使我用纯红色绘制了很多像素,也只有很少的像素。但是当我用眼睛查看图像时,我发现绘制的红色像素没有正确保存为我选择的正确红色(255)。
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).
任何人都可以知道如何解决这个问题?我的意思是使用OpenCV保存图片而不会降低其质量。
Any one does know how to resolve this problem ? I mean to save the pictures using OpenCV without degrading its quality.
推荐答案
JPEG是一种有损格式,您需要保存图像PNG,因为它是一种无损格式。
JPEG is a lossy format, you need to save your images as PNG as it is a lossless format.
这篇关于不损失使用cv2.imwrite()保存的图片的质量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!