OriginLab Corporation - Scientific Graphing and Data Analysis Software - 2D graphs, 3D graphs, Contour Plots, Statistical Charts, Data Exploration, Statistics, Curve Fitting, Signal Processing, and Peak Analysis

imgTrim

Contents

Menu Information

AutoTrim

Brief Information

Trim image with auto threshold settings

Command Line Usage

1. imgTrim t:=20;

2. imgTrim t:=20 img:=1 oimg:=2 o:=3;

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Threshold t

Input

int

0

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.

Input Matrix img

Input

Image

<active>

Specifies the image to be manipulated. The default input is the active image.

Output Image oimg

Output

Image

<input>

Specifies the output image. By default, the output image is the same as the input image. See the syntax here.

Edge o

Input

int

all

Specifies the edges to trim.

Option list

  • all :All boundary
Trims all edges.
  • tl:Top & Left
Trims the top and left edges.
  • br:Bottom & Right
Trims the bottom and right edges.
  • top :Top
Trims the top edge only.
  • left:Left
Trims the left edge only.
  • bottom:Bottom
Trims the bottom edge only.
  • right:Right
Trims the right edge only.

Description

This function trims blank space around the edges of the input image automatically.

Examples

In this example, we use the imgTrim function to trim the empty spaces near the edges of the input image:

  1. When the image is active, select Image: Geometric Transform: AutoTrim to open the dialog of the X-Function.
  2. In the dialog, change the settings as the screenshot below and click OK to close the dialog.
    Image:imgTrim_help_English_files_image002.jpg
    A new image is created. It is the trimmed image.
Image:imgTrim_help_English_files_image004.jpg
Image:imgTrim_help_English_files_image006.jpg
The original image
The output image



For more examples, please refer to XF Script Dialog (press F11).

Algorithm

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.

References

LEADTOOLS Main API Help file, Version 14

Related X-Functions

imgCrop, imgResize, imgShear