Removes the background from the image.
virtual L_INT LBitmap::SubtractBackground (uRollingBall, uShrinkSize, uBrightnessFactor, uFlags)
The radius (in pixels) of the ball that will roll over the entire image to determine the background. Recommended value is 50.
Shrink size ratio used to minimize the image internally in order to increase the speed with little loss of accuracy. Possible values are:
|SBK_DEPEND|| The Shrink Size depends on the ball size.|
|SBK_1_1|| No Resize (Highest accuracy).|
|SBK_1_2|| Resize to half width and height.|
|SBK_1_4|| Resize to quarter width and height.|
|SBK_1_8|| Resize to eighth width and height (very fast).|
Brightness factor for increasing or decreasing the brightness of the image.
Valid values range from 0 to 400. If you pass 100 the brightness remains unchanged. Lower values darken the image while higher values lighten the image.
Flags that indicate whether the background is darker than the foreground, and whether to show the objects without the background. You must select one from each group. Possible values are:
|SBK_BG_DARK||[0x00000000] The background in the current image is darker than the foreground.|
|SBK_BG_BRIGHT||[0x00000001] The background in the current image is brighter than the foreground.|
|SBK_RES_SHOW||[0x00000000] The output bitmap shows the result of the subtraction between the background and the original image.|
|SBK_BG_SHOW||[0x00000010] The output bitmap shows only the background.|
|SUCCESS||The function was successful.|
|< 1||An error occurred. Refer to Return Codes.|
This function is useful, especially with medical images and grayscale bitmaps in correcting non-uniform brightness.
The rolling ball algorithm works as follows:
Consider the bitmap to be a 3-D surface and the z-axis to be the intensity of the image [The component V from the HSV color space].
Roll a 3-D ball beneath the surface so all the points of the ball are under the surface with one or more points of the ball tangent to the surface.
The tangent points to the rolling ball are considered to be the background.
Subtract the background from the original image.
The Rolling Ball Radius should be at least as large as the radius of the largest object in the image that is not part of the background to ensure the separation of the background from any objects.
A small radius allows the detection of small objects, whereas a larger radius will detect both small and large objects.
When subtracting the background, sometimes the result is dim. In such a case you can enhance the brightness after subtracting the background by using the uBrightness factor, which functions similar to LBitmap::Multiply. Passing 100 for uBrightness leaves the brightness unchanged.
Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available only in the Document/Medical toolkits.
To update a status bar or detect a user interrupt during execution of this function, refer to LBase::EnableStatusCallback.
This function does not support signed data images. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image is passed to this function.
This function does not support 32-bit grayscale images. It returns the error code ERROR_GRAY32_UNSUPPORTED if a 32-bit grayscale image is passed to this function.
Subtract Background Function - Before
Subtract Background Function - After
View additional platform support for this Subtract Background function.
L_INT LBitmap__SubtractBackgroundExample(LBitmap *pLeadBitmap)
/* Apply Subtract Background effect on the image*/
return pLeadBitmap->SubtractBackground(50, 0, 0, SBK_BG_DARK | SBK_RES_SHOW);
Medical Web Viewer .NET
.NET, Java, Android, and iOS/macOS Assemblies
C API/C++ Class Libraries