裁剪 JPG 图像尝试使用以下脚本从下方晶圆图图像的外部周围裁剪浅灰色边框。 我想我不明白裁剪消息是如何工作的,因为前后图像没有区别。
知道我做错了什么吗?
干杯,特洛伊
img = open("D:\wafer.jpg", jpg);
win1 = newWindow("Original", img);
img << crop(left(5),right(5),top(5),bottom(5));
win2 = newWindow("Cropped", img);
img << savePicture("D:\waferCropped.jpg", jpg);

脚本编写回复:裁剪 JPG 图像你好,
我认为您忘记将裁剪后的图像分配给变量:
img2 = img << crop(left(5),right(5),top(5),bottom(5));
win2 = newWindow("Cropped", img2);
最好的事物,
TS
回复:裁剪 JPG 图像感谢蒂埃里的回复。
我也曾尝试过,但没有运气。
回复:裁剪 JPG 图像好的,所以看起来我只是不明白裁剪功能是如何工作的。 从根本上说,您需要知道您正在裁剪的图像的高度和宽度,并在裁剪时使用这些值,相对于 LHS 和 TOP Edges
左 = 从左侧移除的像素数
Right =要保留的剩余图像的“宽度”(以像素为单位)
顶部 = 要从图像顶部移除的像素数
要保留的剩余图像的底部 = '高度'(以像素为单位)
img = open("D:\WaferMaps\8PTPCVEB\wafer.jpg", jpg);
imgX = (img << GetSize)[1];
imgY = (img << GetSize)[2];
win1 = newWindow("Original", img);
myTrimBy = 5;
img << crop(left(myTrimBy),right(imgX - myTrimBy), top(myTrimBy), bottom(imgY - myTrimBy));
win2 = newWindow("Cropped", img);
img << savePicture("D:\WaferMaps\8PTPCVEB\waferCropped.jpg", jpg);
回复:裁剪 JPG 图像不错的工作。 您提供的 Right 和 Bottom 定义与您指定的不完全相同。 你的剧本很准!
请参阅下面的脚本。
Names Default To Here( 1 );
img = Open( "$SAMPLE_IMAGES/tile.jpg", jpg );
s = {w,h} = img << get size();
show( s ); //{451, 451}
obj = New Window( "tile(40,40)", img );
Wait( 1 );
img << Crop( Left( 50 ), Right( 100 ), Top( 60 ), Bottom( 150 ) );
s = {w,h} = img << get size();
show( s ); //{50, 90}
//img is a matrix of pixels the initail size is 1 to 451 columns aka "w" width
//and "h" is height 1 to 451 rows
//Crop Left(x) is the starting column and Right(y) is the ending column
//Top() and Bottom() works the same, so after the crop the width is 100-50=50
//and the height is 150-60=90回复:裁剪 JPG 图像亲@Thierry_S ,
我会以同样的方式思考,这种行为很奇怪,正如文档所说:“创建新图像......”。
但实际上crop 正在改变当前图像,所以在我看来,文档是不正确的,它具有误导性。
@tonya_mauldin ,您认为文档必须根据此更改吗?
Names Default To Here( 1 );
img = Open( "$SAMPLE_IMAGES/tile.jpg", jpg );
Print( "Size before crop:", img << get size );
img << Crop(
Left( 50 ),
Right( 400 ),
Top( 50 ),
Bottom( 400 )
);
Print( "Size before crop:", img << get size );
print("So crop changes the image and does not create a new one as written in the documentation");图片 (jmp.com)
回复:裁剪 JPG 图像是的,它是一个不明显的界面,需要更好的文档。 @QianaEaglin
pixels = [
-11 -11 -11 -11 -11 -11 -11 -11 -11,
-11 -11 -91 -99 -99 -99 -99 -92 -11,
-11 -11 -99 -99 -99 -99 -99 -99 -11,
-11 -11 -99 -99 -99 -99 -99 -99 -11,
-11 -11 -99 -99 -99 -99 -99 -99 -11,
-11 -11 -93 -99 -99 -99 -99 -94 -11];
img = New Image( pixels );
{hSize, ySize} = img << size;
Show( img << getsize, img << getpixels );
// crop the -11 out of the image
img << crop( Left( 2 ), Right( 8 ), top( 1 ), bottom( 6 ) );
Show( img << getsize, img << getpixels );
//// img << getsize = {6, 5};
//// img << getpixels =
//// [ -91 -99 -99 -99 -99 -92,
//// -99 -99 -99 -99 -99 -99,
//// -99 -99 -99 -99 -99 -99,
//// -99 -99 -99 -99 -99 -99,
//// -93 -99 -99 -99 -99 -94];
从零开始的像素索引位于像素之间的细线上。