【发布时间】:2016-01-19 23:46:55
【问题描述】:
我正在尝试使用 ImageMagick 6.9.3-1 将医学 X 射线格式转换为更常见的格式,无论是 png、bmp 还是其他格式。我对这种文件格式的文档为零。我对加载图像的软件的访问权限为零。我希望这个很棒的社区可以帮助我。
到目前为止,我已经确定它是一个灰度 jfif,每像素 12 位。
我已编译 ImageMagick 以启用 12 位 jfifs 的解压缩,这问题可能出在哪里,但稍后会详细介绍。
ImageMagick 识别输出没有错误
C:\libjpeg\ImageMagick-6.9.3-1\VisualMagick\bin>identify.exe C:\Users\alexander\
Desktop\708_885_5856.xdr
C:\Users\alexander\Desktop\708_885_5856.xdr JPEG 1896x1368 1896x1368+0+0 12-bit
Gray 4096c 659KB 0.000u 0:00.000
但是,ImageMagick identify -verbose 报告错误“invalid colormap index”
C:\libjpeg\ImageMagick-6.9.3-1\VisualMagick\bin>identify.exe -verbose C:\Users\a
lexander\Desktop\708_885_5856.xdr
Image: C:\Users\alexander\Desktop\708_885_5856.xdr
Format: JPEG (Joint Photographic Experts Group JFIF format)
Mime type: image/jpeg
Class: PseudoClass
Geometry: 1896x1368+0+0
Units: Undefined
Type: Grayscale
Endianess: Undefined
Colorspace: Gray
Depth: 12/16-bit
Channel depth:
gray: 16-bit
Channel statistics:
Pixels: 2593728
Gray:
min: 0 (0)
max: 319.989 (0.0781415)
mean: 0.0593298 (1.44883e-05)
standard deviation: 2.68324 (0.000655247)
kurtosis: 3867.56
skewness: 57.5931
entropy: 0.00257194
Colormap entries: 4096
Colormap:
Rendering intent: Undefined
Gamma: 0.454545
Background color: gray(255)
Border color: gray(223)
Matte color: gray(189)
Transparent color: gray(0)
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 1896x1368+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Quality: 84
Orientation: Undefined
Properties:
comment: ♦
date:create: 2016-01-12T12:53:56-05:00
date:modify: 2016-01-19T16:41:03-05:00
jpeg:colorspace: 1
jpeg:sampling-factor: 1x1
signature: f913f28ee8f54a718a3224d8b097f5cf3086509c6e4229974f4ce8570fd97f6e
Artifacts:
filename: C:\Users\alexander\Desktop\708_885_5856.xdr
verbose: true
Tainted: False
Filesize: 659KB
Number pixels: 2.594M
Pixels per second: 41.2KB
User time: 62.672u
Elapsed time: 1:04.010
Version: ImageMagick 6.9.3-1 Q16 x64 2016-01-19 http://www.imagemagick.org
identify.exe: Invalid colormap index `C:\Users\alexander\Desktop\708_885_5856.xd
r' @ error/colormap-private.h/ConstrainColormapIndex/34.
这对我来说似乎很奇怪,因为 identify 能够计算灰色通道的统计数据,并且“颜色图条目”注册为 4096。
当我尝试使用 ImageMagick 转换其中一张图像时,我最终得到了一个适当大小的灰度图像,它是 100% 黑色像素,并且我收到“无效的颜色图索引”消息。
C:\libjpeg\ImageMagick-6.9.3-1\VisualMagick\bin>convert.exe -verbose C:\Users\al
exander\Desktop\708_885_5856.xdr C:\Users\alexander\Desktop\output.png
C:\Users\alexander\Desktop\708_885_5856.xdr JPEG 1896x1368 1896x1368+0+0 12-bit
Gray 4096c 659KB 61.844u 1:02.400
C:\Users\alexander\Desktop\708_885_5856.xdr=>C:\Users\alexander\Desktop\output.p
ng JPEG 1896x1368 1896x1368+0+0 16-bit Gray 22c 9.73KB 0.391u 0:00.187
convert.exe: Invalid colormap index `C:\Users\alexander\Desktop\708_885_5856.xdr
' @ error/colormap-private.h/ConstrainColormapIndex/34.
“invalid colormap index”错误中引用的代码块是
static inline IndexPacket ConstrainColormapIndex(Image *image,
const size_t index)
{
if ((index < image->colors) && ((ssize_t) index >= 0))
return((IndexPacket) index);
(void) ThrowMagickException(&image->exception,GetMagickModule(),
CorruptImageError,"InvalidColormapIndex","`%s'",image->filename);
return((IndexPacket) 0);
}
这似乎是有道理的,索引进入 > 4095 或
我对 Visual Studio 或 c++ 不是很熟悉,所以请多多包涵。 当我将 libjpeg 设置为读取 12 位图像时,我在 jdct.h 中遇到了一行代码,引起了我的注意。中间一行中间的“UINT32”用红色下划线。
typedef INT32 DCTELEM; /* must have 32 bits */
typedef UINT32 UDCTELEM;
typedef unsigned long long UDCTELEM2;
Visual Studio 无法将 UINT32 识别为有效数据类型。 在将项目加载到 Visual Studio 的过程中,我不得不将项目从 Visual Studio 2010“转换”到 Visual Studio 2015。我担心当我将项目从 Visual Studio 2010“转换”到 Visual Studio 时会出现问题2015. 或者它可能是一个红鲱鱼。
总之,我想我的问题确实是:
- 如何打印索引的值? (如 java "System.println.out(index);")
- 难道我不能在 C 和 C++ 中为 cstd.h 之类的标准数据类型添加一些东西吗?
- 为什么我什至需要彩色地图索引?如果identify可以计算像素值的平均值,那么它显然可以读取每一个,如果它可以读取每一个,为什么它会失败?
- 获得 Visual Studio 2010 最有可能解决我的问题吗?
【问题讨论】:
-
您能否添加一个链接到您失败的图像之一?还是保密?
-
有些事情搞砸了 - JPEG 甚至没有颜色图。您将不得不发布一张图片以获得任何答案。
标签: c++ visual-studio-2010 imagemagick reverse-engineering