裁剪圖像並儲存到新列中我想裁剪圖像並將裁剪後的圖像儲存在新列中。
我的第一個方法是:
for each row (:new col = :old col << crop(...))
……但後來我在社區裡發現了@Craige_Hales 的帖子,
https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/mp/442473/highlight/true#M69072
重要訊息:

因此,我嘗試了這個:
Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );
for each row (:pet = :picture );
wait(0);
for each row (:pet << Crop( Left( 5 ), Right( 10 ), Top( 6 ), Bottom( 100 ) ));
....沒有效果。
在腳本索引中,我發現:

也許使用圖片作為臨時變數?
Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );
for each row( img= :picture;;img << Crop( Left( 5 ), Right( 70 ), Top( 30 ), Bottom( 50 ) );:pet = img)
確實如此:

但是點擊資料表後,我注意到輸入列也發生了變化:

所以,我的最終腳本是:
Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );
for each row( img= new image(:picture);img << Crop( Left( 5 ), Right( 70 ), Top( 30 ), Bottom( 50 ) );:pet = img)
- 使用新圖像()建立新映像
- 調整此影像的大小
- 將其儲存在新列中
自動化和腳本回覆:裁剪影像並儲存到新列中不幸的是,在我的實際資料集中,只有部分影像被裁剪了。
簡單的解釋:我透過從 Powerpoint 簡報中複製/貼上來填充圖像列。
所有圖像都具有相同的縱橫比,因此它們在 JMP 資料網格中具有相同的大小 - 但它們的實際大小並不相同!只有當參數中的像素值小於影像的實際大小時,裁剪才會有效。
當您使用具有不同縱橫比的圖像時(嘗試為社區貼文建立演示案例),更容易檢測。

Open( "$SAMPLE_DATA/SAS Offices.jmp" );
New Column( "cropped", Expression);
for each row( img= new image(:Photo);
{w, h} = img << Get Size;
img << Crop( Left( 10 ), Right( 800 ), Top( 10 ), Bottom( 70 ) );:cropped = img)
所以,我的最終腳本是:
Open( "$SAMPLE_DATA/SAS Offices.jmp" );
New Column( "cropped", Expression );
For Each Row(
try(img = New Image( :Photo );
{w, h} = img << Get Size;
target = 500;
img << scale( 500 / w );
{w, h} = img << Get Size;
img << Crop( Left( Round( w / 3 ) ), Right( Round( w / 3 * 2 ) ), Top( Round( h / 10 ) ), Bottom( Round( h / 5 ) ) );
:cropped = img;)
);
嘗試? -> 萬一其中一張圖片遺失。
回覆:裁剪影像並儲存到新列中這並不難。
我認為困難的部分是:將一張圖片的背景變成透明,並將其疊加到其他圖片上。
JSL沒有讓圖片背景透明的功能。
只能藉助其他軟體才能實現
回覆:裁剪影像並儲存到新列中run program(executable("I:\00\FastStoneIV\magick.exe"),options({目||" -fill none -fuzz 0% -draw \!"color 92,30 floodfill\!" "||标}));
