16 ビット TIFF イメージのインポートJMP が 256 を超えるグレーの階調を持つグレースケール データを読み込めるようにしたいという要望があります。 試してみる前に、Python が妥当な方法かもしれないと提案しました。 Gimp で作成した最初のテスト ファイルは、Python で奇妙なエラー メッセージを生成しました。これは、「16 ビット グレー スケール データは、他のチャネル (アルファ チャネルなど) がない限り、Python でインポートできない」という意味であることがわかりました。層)。" Gimp のデフォルトにはアルファ チャネルがあり、それなしで再エクスポートすると、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.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.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.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.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 倍して、ノイズを可視化します。 私のディスプレイでは、10 倍未満でほぼ均一なグレーです。 切り捨て誤差はグレースケール範囲の約 1/255 です。
2 つのオレンジ色の写真は同じように見えます。 下の画像の分光色への変換は16ビットデータで行っているので、多少の違いはあると思います。 青/灰色/赤のかすかな質感の画像は、2 つのオレンジ色の画像を作成したデータの違いを表しています。 カメラが実際に 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) には 2 つの TIF が添付されています。アルファ データの余分なチャネルが原因で失敗します。 JMP 16 の .zip を削除するか、古い JMP を使用している場合は zip ツールを使用します。
ありがとう@RJ_ベイリー!