有沒有辦法先在 jmp 腳本中轉換影像類型,然後再將其新增至表格中的影像列?我有一堆 .tif 文件,它們駐留在 .zip 檔案中。我可以使用以下腳本將特定圖像中的資料讀取到表中:
dt = New Table( "test", New Column( "Image", Expression ) );
dt << Add Rows( 1 );
za = Open( "tif_library", "zip" );
dat = za << Read( "tif_file_n.tif", Format( blob ) );
img = New Image( dat, "tiff" );
dt:Image = img;
Close( dt, Save("test.jmp", "jmp");<BR />問題是檔案 test.jmp 太大。但是,如果我可以將圖像從 tiff 轉換為 jpeg,則生成的 jmp 表會小得多(並且我可以忍受品質限制)。但我能想到的唯一方法是將圖像保存為 .jpg 文件,然後將其讀回。
dt = New Table( "test", New Column( "Image", Expression ) );
dt << Add Rows( 1 );
za = Open( "tif_library", "zip" );
dat = za << Read( "tif_file_n.tif", Format( blob ) );
img = New Image( dat, "tiff" );
img << Save Image( "temp.jpg", "jpeg");
img1 = New Image( "temp.jpg" );
dt:Image = img1;
Close( dt, Save("test.jmp", "jmp");有沒有一種簡單的方法可以在 JMP 中執行此操作,而無需寫入檔案並將其讀回?謝謝您的明智建議!
正如您所注意到的,JMP 嘗試透過保留檔案的原始版本來避免重新壓縮映像檔。 如果 JMP 無法確定原始格式,JMP 可能會保留 PNG 表示形式而不是 JPG。 根據 TIFF 實際包含的內容,PNG 可能是您所需要的,或足夠好。 您可以在不使用中間磁碟檔案的情況下執行此操作,如下所示:
dt = New Table( "test", New Column( "Image", Expression ) );
dt << Add Rows( 1 );
// no tiff handy, but like this:
img = open("C:\Users\chales\Pictures\after.jpg","jpg");
//dt:Image = img;
img<<SCALE></SCALE>
<
PNG 是一種無損壓縮格式,特別適合 JMP 創建的圖形(具有硬邊緣)等圖像。 JPG 是一種有損壓縮,適用於邊緣較柔和的現實世界相機影像。 TIFF 檔案可以保存多種格式,包括龐大的未壓縮原始像素格式。 在上面的範例中,「after.jpg」是一張大相機圖片,比 png 更大。 您可能更喜歡現有的方法。