16 位 TIFF 图像导入JMP 希望能够加载灰度超过 256 级的灰度数据。 我建议在尝试之前使用 Python 可能是一种合理的方法。 我用 Gimp 创建的第一个测试文件在 Python 中产生了一条奇怪的错误消息,我追踪到它的意思是“Python 无法导入 16 位灰度数据,除非没有其他通道(如 alpha 通道,或其他层)。” Gimp 中的默认设置有一个 alpha 通道,并且在没有它的情况下重新导出会生成 Python 可以加载的 16 位灰度文件。 以下是 8 位 PNG 屏幕截图。 第一张图片是 Gimp 的一点熔岩,它被保存为 16 位灰度。
The delta noise image is multiplied by 30 to make the noise visible. It is nearly uniform gray on my display at < 10X. The truncation error is about 1/255 of the gray scale range.增量噪声图像乘以 30 使噪声可见。 在 < 10X 时,它在我的显示器上几乎是均匀的灰色。 截断误差约为灰度范围的 1/255。
两张橙色图片看起来一模一样。 底部图像上光谱颜色的转换是使用 16 位数据完成的,因此可能存在一些差异。 微弱纹理的蓝色/灰色/红色图像代表了制作两个橙色图像的数据之间的差异。 如果您的相机实际上可以产生 10 位或 12 位甚至 14 位数据,那么额外的精度可能很重要。 或者,动态范围可能很重要。
Python Init();
path = Convert File Path(
Save Text File( "$temp/deleteme.tiff", // the 2channel file will fail - see link in message
Load Text File( "16bitgray1channel.tif", blob() ) // pic is part of the project, move to $temp
),
"windows"
);
// first import it using built-in image that truncates the bit depth
truncated = Color To RGB( New Image( path ) << getpixels )[1]; // use the red channel
// stretch truncated image bit depth 0 to 1
r = Range( truncated );//[0.00784 0.803]
min = r[1];
max = r[2];
truncated = (truncated - min) / (max - min); // 0 to 1
timage = New Image( Heat Color( 1 - truncated, "spectral" ) );
// now import with Python PIL to preserve the 16-bit depth
rc = Python Execute( {path}, {im}, "\[
import numpy as np
import PIL
from PIL import Image
try:
im = np.array(Image.open(path))
except Exception as e:
print("make sure there is only one channel (no alpha for example) see https://github.com/python-pillow/Pillow/issues/1888",e)
]\" );
If( rc, Throw( "python code failed" ) );
// stretch full image bit depth 0 to 1
r = Range( im ); //[530 52698]
min = r[1];
max = r[2];
full = (im - min) / (max - min);
fimage = New Image( Heat Color( 1 - full, "spectral" ) );
// diff and magnify the difference
magnify = 30;
delta = (full - truncated) * magnify; // small negative and positive diffs, scaled up to be visible
delta = delta + .5; // center
dimage = New Image( Heat Color( delta ) );
New Window( "compare", Lineup Box( N Col( 2 ),
textbox("original\!ngray\!nscale"),New Image( path ),
Text Box( "truncated\!nheatcolor\!nspectral" ), timage,
Text Box( evalinsert("delta\!ntimes ^magnify^\!nblue\!nto gray\!nto red\!n\!nfullres -\!ntruncated") ),
dimage, Text Box( "full res\!nheatcolor\!nspectral" ), fimage, ) );
项目文件 (JMP 16) 附有两个 TIF;一个失败是因为额外的 alpha 数据通道。 删除 JMP 16 的 .zip,或者如果您使用的是旧版 JMP,则使用您的压缩工具。
谢谢@RJ_Bailey !