简体   繁体   English

使用imwrite opencv python函数在写入相同图像后更改像素值

[英]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.

相关问题 在python opencv中写入和/或读取后的图像像素值 - Image pixels values after imwrite and/or imread in python opencv 如何在Linux中使用名为“imwrite”的python opencv函数将捕获的图像文件保存在USB中 - How to save the capture image file in USB using python opencv function named "imwrite" in Linux imwrite OpenCV 不在 ec2 实例中写入图像 - imwrite OpenCV not writing an image in ec2 instance 使用imwrite进行阈值处理后如何在opencv中保存图像 - How to save image in opencv after thresholding using imwrite 我正在尝试使用 opencv python 库使用 cv2.imwrite() function 将图像保存到文件,但它显示错误 - I am trying to save an image to a file by using opencv python library using cv2.imwrite() function but it shows an error 使用 opencv 获取由椭圆包围的图像区域中的像素坐标和像素值 python - Getting pixel coordinates and pixel values in image region bounded by an ellipse using opencv python 使用 opencv、numpy 和 python 在图像中搜索像素 - Searching for a pixel in an image using opencv, numpy and python OpenCV-在将图像写入文件时指定格式(cv2.imwrite) - OpenCV - specify format while writing image to file (cv2.imwrite) 使用opencv的matlplotlib提供具有相同像素值的不同图像 - matlplotlib with opencv gives a different image with the same pixel values IndexError 使用 OpenCV imwrite - IndexError using OpenCV imwrite
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM