我在创建无损 PNG 图像吗? [英] Am I creating lossless PNG images?

查看:60
本文介绍了我在创建无损 PNG 图像吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在科学背景下进行图像处理.每当我需要将图像保存到硬盘驱动器时,我都希望能够在以后重新打开它并准确获取保存前的数据.我只使用 PNG 格式,一直认为它是一种无损格式.如果我没有使用错误的位深度,这总是正确的吗?编码器和解码器应该完全没有作用吗?具体来说,我保存的图像

I am doing image processing in a scientific context. Whenever I need to save an image to the hard drive, I want to be able to reopen it at a later time and get exactly the data that I had before saving it. I exclusively use the PNG format, having always been under the impression that it is a lossless format. Is this always correct, provided I am not using the wrong bit-depth? Should encoder and decoder play no role at all? Specifically, the images I save

  • 以 2D numpy 数组的形式存在
  • 具有从 0 到 255 的整数值
  • 使用 OpenCV imwrite() 函数进行编码,例如cv2.imwrite("image.png", array)
  • are present as 2D numpy arrays
  • have integer values from 0 to 255
  • are encoded with the OpenCV imwrite() function, e.g. cv2.imwrite("image.png", array)

推荐答案

PNG 是一种 无损格式设计:

由于 PNG 的压缩是完全无损的——并且因为它支持高达 48 位真彩色或 16 位灰度——与标准 JPEG 不同,保存、恢复和重新保存图像不会降低其质量(即使在其最高质量设置).

Since PNG's compression is fully lossless--and since it supports up to 48-bit truecolor or 16-bit grayscale--saving, restoring and re-saving an image will not degrade its quality, unlike standard JPEG (even at its highest quality settings).

在正确读取图像方面,编码器和解码器应该无关紧要.(当然,假设它们没有问题).

The encoder and decoder should not matter, in regards of reading the images correctly. (Assuming, of course, they're not buggy).

与 TIFF 不同的是,PNG 规范没有为实现者选择他们将支持的功能留下空间;结果是保存在一个应用程序中的 PNG 图像可以在任何其他支持 PNG 的应用程序中读取.

And unlike TIFF, the PNG specification leaves no room for implementors to pick and choose what features they'll support; the result is that a PNG image saved in one app is readable in any other PNG-supporting application.

这篇关于我在创建无损 PNG 图像吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆