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

imgSubtractBg

Contents

Menu Information

Subtract Background

Brief Information

Subtract image background

Additional Information

This feature is for OriginPro only.

Command Line Usage

1. imgSubtractBg r:=80;

2. imgSubtractBg r:=50 s:=s2 i:=80;

3. imgSubtractBg s:=s8 bg:=bright oimg:=mat(2);

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Input Matrix img

Input

Image

<active>

Specifies the input image. The default input is the active image.

Rolling Ball r

Input

int

20

Specifies the radius (in pixels) of the ball that will roll over the entire image to determine the background.

Shrink Size s

Input

int

radius

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.
Option list

  • radius:Depend on Radius
    Shrinks the input image depending on the radius of the rolling ball.
  • s0:No Shrink
    Does not shrink the input image.
  • s2:Shrink 1/2
    Resizes the input image to half width and height.
  • s4:Shrink 1/4
    Resizes the input image to quarter width and height.
  • s8:Shrink 1/8

Resizes the input image to eighth width and height

Brightness i

Input

int

100

Specifies a brightness factor for increasing or decreasing the brightness of the image. Valid values range from 0 to 400.

Background bg

Input

int

dark

Specifies whether or not the background is darker than the foreground.
Option list

  • dark:Darker than the Foreground
    The background is darker than the foreground.
  • bright:Brighter than the Foreground
    The background is brighter than the foreground.
Show show

Input

int

result

Specifies whether to show the subtraction result or the background in the output image.
Option list

  • result:Result
    The output image shows the result of the subtraction between the background and the original image.
  • bg:Background
    The output bitmap shows only the background.
Output Image oimg

Output

Image

<new>

Specifies the output image. By default, a new image will be created and used as output.

See the syntax here.

Description

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.

Examples

In this example, we use the imgSubtractBg function to subtract the background from the input image:

  1. When the input image is active, select Image: Arithmetic Transform: Subtract Background. This opens the dialog of the X-Function.
  2. In the X-Function dialog, change the settings as the screenshot below and click OK to close the dialog.
    Image:imgSubtractBg_help_English_files_image002.jpg
    A new image is created as a result. We can see that the background is subtracted from the input image and the output image is brighter than the input.
Image:imgSubtractBg_help_English_files_image004.jpg
Image:imgSubtractBg_help_English_files_image006.jpg
Input image
Output image


Algorithm

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.

References

LEADTOOLS Main API Help file, Version 14

Related X-Functions

imgReplaceBg, imgSubtractInterpBG, imgMathfun, imgPixlog