【发布时间】:2013-12-27 10:13:49
【问题描述】:
我计算一组 16 位无符号 .tiff 图像的平均图像,并用 Imagick 保存:
// Image averaging
$img_aux = new Imagick();
$num_rows = 0;
while ($row = $sql->fetch()) {
$num_rows++;
$file = $row['File'];
if ($num_rows == 1) {
$img_avg = new Imagick();
if (!$img_avg->readImage($file)) throw new Exception("Problem averaging the images");
}
else {
if (!$img_aux->readImage($file)) throw new Exception("Problem averaging the images");
$opacity = 1.0 / (1.0 * $num_rows);
$img_aux->setImageOpacity($opacity);
$img_avg->setImageOpacity(1 - $opacity);
$img_avg->compositeImage($img_aux, imagick::COMPOSITE_PLUS, 0, 0);
};
};
// Save image
$save_file = tempnam($globals['path_img'], '');
$img_avg->setImageFormat("tiff");
$img_avg->setImageDepth(16);
if (!$img_avg->writeImage($save_file)) throw new Exception("Problem averaging the images");
$img_avg->destroy();
我返回的图像已正确打开并在多个查看器中显示,但在 Imagej 中没有。 Imagej 将新图像识别为 32 位 RGB。
为什么?我该如何解决这个问题?
示例:
16 位 tiff 图像:https://www.dropbox.com/s/1971mez6478ktqp/test.tif
两次图像的平均值:https://www.dropbox.com/s/di1e9x4y9007r6y/average.tif
【问题讨论】:
-
您是否按照@ctrueden 的建议尝试过使用生物格式?如果您提供示例图片会很有帮助。
-
@JanEglinger 我必须在没有 Bio-Formats 插件的情况下使用 Imagej。您现在可以下载示例。
-
我只能同意 ctrueden 的建议,将其发布到 ImageJ 邮件列表(包括示例图像)以修复错误。顺便说一句,Bio-Formats 正在正确打开这两个文件。直接使用 ImageJ 打开时的区别似乎在于 TIFF-Tag 258(“BitsPerSample”),其中我得到 value=218, count=3 for test.tif 和 value=5898510 , count=4 当调试模式处于活动状态时为 average.tif。
-
Wayne Rasband 不太可能在 Stack Overflow 上看到这个问题,他保留了对 ImageJ1 代码库的唯一控制权。因此,在 ImageJ1 核心中修复此错误的唯一方法是发布到 ImageJ 邮件列表。也就是说,ImageJ 2.0.0 版本(将于 6 月 1 日发布)将统一 File > Open 的行为以首先使用 SCIFIO 库,它使用与 Bio-Formats 基本相同的代码来打开 TIFF。所以这个问题很快就会得到解决。
-
另外,我很好奇为什么你“必须在没有 Bio-Formats 插件的情况下使用 Imagej”。这是您的机构规定的吗?如果有,为什么?
标签: php image-processing imagemagick tiff imagej