Importazione di immagini TIFF a 16 bit è il desiderio che JMP sia in grado di caricare i dati in scala di grigi con più di 256 sfumature di grigio. Ho suggerito che Python potrebbe essere un modo ragionevole per farlo prima di provarlo. Il primo file di test che ho creato con Gimp ha prodotto uno strano messaggio di errore in Python, che ho rintracciato per indicare "i dati in scala di grigi a 16 bit non possono essere importati da Python a meno che non ci sia un altro canale (come un canale alfa o altro strato)." L'impostazione predefinita in Gimp ha un canale alfa e la riesportazione senza di esso ha creato un file in scala di grigi a 16 bit che Python può caricare. Quella che segue è una cattura dello schermo PNG a 8 bit. La prima immagine è un po' di lava di Gimp, che è stata salvata come scala di grigi a 16 bit.
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.L'immagine del rumore delta viene moltiplicata per 30 per rendere visibile il rumore. È grigio quasi uniforme sul mio display a <10X. L'errore di troncamento è circa 1/255 dell'intervallo della scala di grigi.
Le due immagini arancioni sembrano identiche. La conversione ai colori spettrali sull'immagine in basso è stata eseguita utilizzando dati a 16 bit, quindi probabilmente ci sono alcune differenze. L'immagine blu/grigia/rossa leggermente strutturata rappresenta la differenza tra i dati che hanno creato le due immagini arancioni. Se la tua fotocamera può effettivamente produrre dati a 10 o 12 o forse anche a 14 bit, quella precisione extra potrebbe essere importante. Oppure, la gamma dinamica può essere importante.
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, ) );
Un file di progetto (JMP 16) è allegato con due TIF; uno fallisce a causa del canale extra di dati alfa. Rimuovi il file .zip per JMP 16 o utilizza i tuoi strumenti zip se stai utilizzando una versione precedente di JMP.
Grazie @RJ_Bailey !