Recortar una imagen JPGIntentando recortar el borde gris claro alrededor del exterior de la imagen de mapa de obleas de abajo usando la siguiente secuencia de comandos. Supongo que no entiendo cómo funciona el mensaje de recorte, ya que no hay diferencia entre las imágenes de antes y después.
¿Alguna idea de lo que estoy haciendo mal?
Saludos, Troy
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);

ScriptingRe: recortar una imagen JPGHola,
Creo que olvidaste asignar la imagen recortada a una variable:
img2 = img << crop(left(5),right(5),top(5),bottom(5));
win2 = newWindow("Cropped", img2);
Mejor,
TS
Re: recortar una imagen JPGGracias por la respuesta Thierry.
También había intentado exactamente eso, pero sin suerte.
Re: recortar una imagen JPGBien, parece que simplemente no entendí cómo funciona la función de recorte. Básicamente, necesita saber la altura y el ancho de la imagen que está recortando y trabajar con esos valores cuando recorta, en relación con los bordes LHS y SUPERIOR.
Izquierda = Número de píxeles para eliminar del lado izquierdo
Derecha = 'Ancho' (en píxeles) de la imagen restante para mantener
Superior = Número de píxeles para eliminar de la parte superior de la imagen
Abajo = 'Altura' (en píxeles) de la imagen restante para mantener
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);
Re: recortar una imagen JPGBuen trabajo. Las definiciones Derecha e Inferior que proporcionó no son exactamente las que especificó. ¡Tu guión es perfecto!
Vea el guión a continuación.
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=90Re: recortar una imagen JPGquerido @Thierry_S ,
Yo hubiera pensado lo mismo, este comportamiento es extraño, como dice la documentación: "crea nueva imagen ...".
Pero, de hecho, el recorte está cambiando la imagen actual, por lo que a mis ojos la documentación no es correcta, es engañosa.
@tonya_mauldin , ¿cree que la documentación debe cambiarse de acuerdo con esto?
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");Imágenes (jmp.com)
Re: Recortar una imagen JPGSí, es una interfaz no obvia y quiere una mejor documentación. @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];
Los índices de píxeles basados en cero están en las líneas finas entre los píxeles.