
Contents |
Subtract Background
Subtract image background
This feature is for OriginPro only.
1. imgSubtractBg r:=80;
2. imgSubtractBg r:=50 s:=s2 i:=80;
3. imgSubtractBg s:=s8 bg:=bright oimg:=mat(2);
| Display Name | Variable Name | I/O and Type | Default Value | Description |
|---|---|---|---|---|
| Input Matrix | img |
Input Image | |
Specifies the input image. The default input is the active image. |
| Rolling Ball | r |
Input int | |
Specifies the radius (in pixels) of the ball that will roll over the entire image to determine the background. |
| Shrink Size | s |
Input int | |
Specifies how to shrink the input image internally. If the image is minimized, the computation speed will increase, but the accuracy will decrease. Note that the shrinking will not affect the input image.
Resizes the input image to eighth width and height |
| Brightness | i |
Input int | |
Specifies a brightness factor for increasing or decreasing the brightness of the image. Valid values range from 0 to 400. |
| Background | bg |
Input int | |
Specifies whether or not the background is darker than the foreground.
|
| Show | show |
Input int | |
Specifies whether to show the subtraction result or the background in the output image.
|
| Output Image | oimg |
Output Image | |
Specifies the output image. By default, a new image will be created and used as output. See the syntax here. |
This X-function detects and removes the background from the image. Note that it only works well for simple background, where the background is significantly brighter or darker than the foreground.
In this example, we use the imgSubtractBg function to subtract the background from the input image:

The computation mainly uses L_SubtractBackgroundBitmap() function from LEADTOOLS Main API. Please refer to the LEADTOOLS Main API Help file, Version 14 and read the L_SubtractBackgroundBitmap topic.
LEADTOOLS Main API Help file, Version 14