16비트 TIFF 이미지 가져오기 JMP가 256개 이상의 회색 음영으로 회색조 데이터를 로드할 수 있기를 바랍니다. 나는 그것을 시도하기 전에 Python이 합리적인 방법일 수 있다고 제안했습니다. Gimp로 만든 첫 번째 테스트 파일은 Python에서 이상한 오류 메시지를 생성했습니다. "16비트 그레이 스케일 데이터는 다른 채널(예: 알파 채널 또는 기타 층)." Gimp의 기본값에는 알파 채널이 있으며 이를 사용하지 않고 다시 내보내면 Python이 로드할 수 있는 16비트 회색조 파일이 만들어집니다. 다음은 8비트 PNG 화면 캡처입니다. 첫 번째 이미지는 16비트 그레이 스케일로 저장된 Gimp의 약간의 용암입니다.
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가 첨부되어 있습니다. 하나는 알파 데이터의 추가 채널 때문에 실패합니다. JMP 16용 .zip을 제거하거나 이전 JMP를 사용하는 경우 zip 도구를 사용하십시오.
감사해요 @RJ_베일리 !