【问题标题】:ImageMagick: split multipage 32 float TIFF imageImageMagick:拆分多页 32 浮动 TIFF 图像
【发布时间】:2016-12-10 21:27:09
【问题描述】:

我正在尝试将 32 位多页 TIFF 图像转换为多个单个 TIFF 图像。

来自here的命令

convert -depth 32 temp.tif single%d.tif

convert: Unknown field with tag 33550 (0x830e) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 33922 (0x8482) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34735 (0x87af) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34736 (0x87b0) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34737 (0x87b1) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 42113 (0xa481) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Sorry, can not handle images with 32-bit samples. `temp.tif' @ error/ti
ff.c/TIFFErrors/565.
convert: Unknown field with tag 33550 (0x830e) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 33922 (0x8482) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34735 (0x87af) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34736 (0x87b0) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34737 (0x87b1) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 42113 (0xa481) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Sorry, can not handle images with 32-bit samples. `temp.tif' @ error/ti
ff.c/TIFFErrors/565.
convert: Unknown field with tag 33550 (0x830e) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 33922 (0x8482) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34735 (0x87af) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34736 (0x87b0) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34737 (0x87b1) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 42113 (0xa481) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Sorry, can not handle images with 32-bit samples. `temp.tif' @ error/ti
ff.c/TIFFErrors/565.
convert: Unknown field with tag 33550 (0x830e) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 33922 (0x8482) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34735 (0x87af) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34736 (0x87b0) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34737 (0x87b1) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 42113 (0xa481) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Sorry, can not handle images with 32-bit samples. `temp.tif' @ error/ti
ff.c/TIFFErrors/565.
convert: Unknown field with tag 33550 (0x830e) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 33922 (0x8482) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34735 (0x87af) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34736 (0x87b0) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34737 (0x87b1) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 42113 (0xa481) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Sorry, can not handle images with 32-bit samples. `temp.tif' @ error/ti
ff.c/TIFFErrors/565.
convert: Unknown field with tag 33550 (0x830e) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 33922 (0x8482) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34735 (0x87af) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34736 (0x87b0) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 34737 (0x87b1) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Unknown field with tag 42113 (0xa481) encountered. `TIFFReadDirectory'
@ warning/tiff.c/TIFFWarnings/905.
convert: Sorry, can not handle images with 32-bit samples. `temp.tif' @ error/ti
ff.c/TIFFErrors/565.

默认情况下似乎无法处理 32 位图像convert: Sorry, can not handle images with 32-bit samples

convert -version

Version: ImageMagick 7.0.2-6 Q16 x64 2016-07-30 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pa
ngocairo png ps rsvg tiff webp xml zlib

ImageMagick 有什么办法吗?

【问题讨论】:

  • 您有可以分享的示例图片吗?
  • @MarkSetchell 是的,这里是示例rgho.st/6j5HNLvXx

标签: image-processing imagemagick tiff imagemagick-convert


【解决方案1】:

格式具有高度可扩展性,我建议查找/研究用于生成图像的专有软件。

Mark's fantastic answer 之后,我能够研究以下内容...

私人 Tiff 标签

TIFF 错误

convert:抱歉,无法处理具有 32 位样本的图像。 `temp.tif'@error/tiff.c/TIFFErrors/564

此消息来自 ImageMagick 链接到的 libtiff 库。它根本不支持每个样本 32 位的 TIFFTAG_BITSPERSAMPLE。这是 tiff 库使用的 TIFFRGBAImageBegin 方法的 code-sn-p。

TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &img->bitspersample);
switch (img->bitspersample) {
case 1: case 2: case 4:
case 8: case 16:
break;
default:
sprintf(emsg, "Sorry, can not handle images with %d-bit samples",
    img->bitspersample);
return (0);
}

替代 tiffsplit

如果任务只是将这些层分解成孤立的图像,那么tiffsplit 可能会起作用...

tiffsplit temp.tif single_

...这将生成single_aaa.tifsingle_aab.tif 等。

但是图像的最后一层出现损坏:(

【讨论】:

  • 此时我不需要 TIFF 元数据,因此可以将其删除。似乎 TIFF lib 不支持 3 通道 32 位图像,但它应该支持 32 位单通道图像,这是我的情况。
【解决方案2】:

嗯,我已经尝试了 ImageMagick 的 Q16 和 Q32、HDRI 和非 HDRI 版本,以及这些选项的大多数组合:

  • -定义量子:格式=浮点数
  • -深度 32
  • -定义 tiff:ignore-tags=42113,34737,34736
  • -定义量子:格式=签名

我也无处可去!

我确实取得了一些成功,我认为 vips 是一个相当轻量级、易于安装的软件包,但它有点取决于您之后想要对数据做什么:

您可以使用以下方法将每个“页面”直接从 TIF 转换为 32 位 PNG:

vips im_vips2png temp.tif:1 1.png
vips im_vips2png temp.tif:2 2.png

或者,您可以通过PPM 格式进行长期循环:

# Convert first "page" in TIF to vips format
vips im_tiff2vips temp.tif:1 1.v

# Convert second "page" in TIF to vips format
vips im_tiff2vips temp.tif:2 2.v

...所有 5 个页面以此类推。

然后我可以使用 vips 将它们转换为浮动 PPM

vips ppmsave 1.v 1.ppm
vips ppmsave 2.v 2.ppm

现在 ImageMagick 可以处理 PPM 文件了:

convert 1.ppm a.png

这取决于你接下来想做什么......

【讨论】:

  • 问题是我不需要 pngppm 结果我需要 32 位 tiff。
  • 似乎可行:"bin/vips.exe" im_tiff2vips temp.tif:1 1.v "bin/vips.exe" tiffsave 1.v 1.tiff
  • 还可以在Ubuntu 12.04 (sudo apt-get install libvips-tools) 上工作,例如vips im_vips2tiff dem_1.tif:1 1.tif
  • 索引也从0开始。所以应该是vips im_vips2tiff dem_1.tif:0 1.tif
  • 另外一个问题是如何在生成的1.tif 图像中保存元数据?在转换过程中,它会打印很多 vips warning: TIFFReadDirectory: Unknown field with tag 33550 (0x830e) encountered ,在这里部分解决:gis.stackexchange.com/questions/283740/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-08-28
相关资源
最近更新 更多