python - 使用opencv写入后,图像中的标题信息丢失

标签 python opencv image-processing tiff qgis

我正在使用open-cv python对图像进行补充,而在写入图像时,open-cv并未在补充图像中写入 header 信息。我的图像数据为TIFF格式。

我正在这样...

import cv2
img = cv2.imread("image.tiff", -1)
for i in xrange(0, len(img)):
     for j in xrange(0, len(i)):
          img[i][j] = 65535-img[i][j]
cv2.imwrite("complemented.tif", img)

最佳答案

如该linkEach TIFF file begins with a image file header which points to one or more image file directories, which contain the image data and image information.中所述,多图像TIFF需要 header 信息。

多图像TIFF在OpenCV中是not supported,如注释中提到的@Haris。

由于不支持多图像TIFF,因此很可能不会使用imread读取 header 信息,因此无法使用imwrite写入 header 信息。

关于python - 使用opencv写入后,图像中的标题信息丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21599464/

相关文章:

python-pptx 库 : Slide Masters of different Powerpoint templates are of different order (index)

linux - 如何使用基于linux的平台在windows硬盘上构建linux共享库?

python - 在 python 中使用 opencv 检测低对比度图像中的正方形,以便通过 tesseract 读取

c++ - 在 OpenCV 中检索当前帧号

Python list() vs 列表理解构建速度

python - Django - 在模型方法中调用 self 保存

python - 将图像转换为适当的尺寸 PyTorch

c++ - C++中的图像处理

python - 使用 OpenSSL 静态编译 Python 3.6

Python - 在图像中查找主要/最常见的颜色