且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2023-11-09 14:36:16

在任何库或工具中重写或保存"图像将始终创建一个新文件或新像素值".发生这种情况是因为正在处理图像以某种质量进行保存.保存的图像质量和大小取决于执行保存的库.因此,需要提供默认值,深度,压缩等.

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.

如果您只想在新文件中创建图像的副本,则可以直接通过 sys 复制该文件,也可以二进制读取整个文件并将其写入新文件-不使用任何文件图像处理库.

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.