Recadrer une image JPGEssayez de recadrer la bordure gris clair autour de l'extérieur de l'image ci-dessous wafermap à l'aide du script suivant. Je suppose que je ne comprends pas comment fonctionne le message de recadrage car il n'y a pas de différence entre les images avant et après.
Une idée de ce que je fais mal?
Salut, Troie
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);

ScriptRe: Recadrer une image JPGSalut,
Je pense que vous avez oublié d'affecter l'image recadrée à une variable :
img2 = img << crop(left(5),right(5),top(5),bottom(5));
win2 = newWindow("Cropped", img2);
Meilleur,
ST
Re: Recadrer une image JPGMerci pour la réponse Thierry.
J'avais essayé exactement cela aussi mais sans succès.
Re: Recadrer une image JPGOK, il semble donc que je n'ai tout simplement pas compris comment fonctionne la fonction de recadrage. Fondamentalement, vous devez connaître la hauteur et la largeur de l'image que vous recadrez et travailler avec ces valeurs lorsque vous recadrez, par rapport aux bords LHS et TOP
Gauche = nombre de pixels à supprimer du côté gauche
Droite = 'Largeur' (en pixels) de l'image restante à conserver
Haut = nombre de pixels à supprimer du haut de l'image
Bas = 'Hauteur' (en pixels) de l'image restante à conserver
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: Recadrer une image JPGBon travail. Les définitions de droite et de bas que vous avez fournies ne correspondent pas exactement à celles que vous avez spécifiées. Votre script est parfait !
Voir le script ci-dessous.
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: Recadrer une image JPGcher @Thierry_S ,
J'aurais pensé la même chose, ce comportement est étrange, comme le dit la documentation : "crée une nouvelle image...".
Mais en fait le recadrage modifie l'image actuelle, donc à mes yeux la documentation n'est pas correcte, elle est trompeuse.
@tonya_mauldin , pensez-vous que la documentation doit être modifiée en conséquence ?
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");Images (jmp.com)
Re : Recadrer une image JPGOui, c'est une interface non évidente et veut une meilleure doc. @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];
Les index de pixel de base zéro se trouvent sur les lignes fines entre les pixels.