[英]Changing of pixel values after writing the same image using imwrite opencv python function
import cv2
import numpy as np
im=cv2.imread('test.jpg')
cv2.imwrite('result.jpg',im)
Here test.jpg have size 19 KB and result.jpg have 41 KB even though they are same images. 这里test.jpg的大小为19 KB,而result.jpg有41 KB,即使它们是相同的图像。
I observed that there is change in the pixel values of these two images. 我观察到这两个图像的像素值发生了变化。
How to prevent this one ? 如何防止这一个?
Re-writing or 'saving' an image in any library or tool will always create a new file or 'new pixel values'. 在任何库或工具中重写或“保存”图像将始终创建新文件或“新像素值”。 This happens because the image is being processed for saving at a certain quality.
发生这种情况是因为正在处理图像以保存一定质量。 The saved image quality and size depends on the library doing the save.
保存的图像质量和大小取决于执行保存的库。 So default values, depth, compression, etc. need to be provided.
因此需要提供默认值,深度,压缩等。
If you just want to create a copy of the image in a new file, either copy the file directly via sys
or binary read the whole file and write it to a new one - without using any image processing libs. 如果您只想在新文件中创建图像的副本,请直接通过
sys
或二进制文件复制文件,然后将其写入新文件 - 不使用任何图像处理库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.