Performs semi-automatic segmentation (using the Levelset algorithm) by shrinking or expanding a contour represented by a region to the objects in the image.
#include "Ltimgcor.h"
L_LTIMGCOR_API L_INT L_LevelsetBitmapRgn(pBitmap, LambdaIn, LambdaOut)
Pointer to the bitmap handle to be segmented.
Represents the weight of moving the contour inside. The default value is 1.
Represents the weight of moving the contour outside. The default value is 1.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
If the image has no region this function assumes a rectangular region that covers the entire image.
The Levelset algorithm finds the best-fitting contour that encapsulates the object.
Equal values for LambdaIn
and LambdaOut
allow the algorithm to decide whether to shrink or expand the selected region.
This function supports 12- and 16-bit grayscale and 48- and 64-bit color images.
This function supports signed/unsigned images.
Levelset Region Function - Before
Levelset Region Function - After
View additional platform support for this Levelset Region function.
Win32, x64, Linux.
This example loads a bitmap and applies Levelest segmentation.
L_INT LevelsetBitmapRgnExample(L_VOID)
{
L_INT nRet;
BITMAPHANDLE LeadBitmap; /* Bitmap handle to hold the loaded image. */
/* Load the bitmap, keeping the bits per pixel of the file */
nRet = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("DICOM\\IMAGE3.dcm")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGRORGRAY, NULL, NULL);
if (nRet != SUCCESS)
return nRet;
RECT MainRect;
MainRect.left = 200;
MainRect.right = 300;
MainRect.top = 200;
MainRect.bottom = 250;
// set region
L_SetBitmapRgnRect(&LeadBitmap, NULL, &MainRect, L_RGN_SET);
// found level set region
nRet = L_LevelsetBitmapRgn(&LeadBitmap, 1, 1);
if (nRet != SUCCESS)
return nRet;
nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &LeadBitmap, FILE_BMP, 24, 0, NULL);
if (nRet != SUCCESS)
return nRet;
//free bitmap
if (LeadBitmap.Flags.Allocated)
L_FreeBitmap(&LeadBitmap);
return SUCCESS;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document