AutoTrim
Trim image with auto threshold settings
1. imgTrim t:=20; 2. imgTrim t:=20 img:=1 oimg:=2 o:=3;
Please refer to the page for additional option switches when accessing the x-function from script
Input
int
Specifies the threshold value for detecting blank space. This X-Function starts at each edge of the input image and scans toward the center. If it finds that the change in intensity that is less than or equal to the threshold, the current area will be considered blank space. Valid values of this variable range from 0 to 255.
Image
Specifies the image to be manipulated. The default input is the active image.
Output
Specifies the output image. By default, the output image is the same as the input image. See the syntax here.
Specifies the edges to trim.
Option list
This function trims blank space around the edges of the input image automatically.
// Rotate image and trim empty areas //Create a new folder in the Project Explorer pe_mkdir RotateTrim path:=aa$; pe_cd aa$; //Create a matrix and import an image into it window -t m; fname$ = System.path.program$ +"samples\Image Processing and Analysis\rice.bmp"; impimage; window -r %h Original; matrix -pg DIM nCol1 nRow1; //Get the dimension of the original iamge window -d; //Duplicate the image window -r %h Modified; imgRotate angle:=42; imgTrim t:=17; matrix -pg DIM nCol2 nRow2; //Get the dimension of the modified iamge window -s T; //Tile the windows horizontally //Report window -n n Report; old = type.redirection; type.redirection = 2; type.notes$=Report; type "Dimension of the original image: "; type " $(nCol1) * $(nRow1)\r\n"; type "Dimension of the modified image: "; type " $(nCol2) * $(nRow2)\r\n"; type.redirection = old;
The computation uses L_TrimBitmap() function from LEADTOOLS Main API. Please refer to the LEADTOOLS Main API Help file, Version 14 and read the L_TrimBitmap topic.
LEADTOOLS Main API Help file, Version 14
imgCrop, imgResize, imgShear