Separates the image into different segments using the Watershed algorithm.
#include "ltwrappr.h"
virtual L_INT LBitmap::WatershedBitmap(ppPoints, pLengths, nSize)
Holds the initial point/path that represents the point or path from which to segment the bitmap.
Number of points in each path.
Number of paths.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
Each segment's pixels have the same color. The Watershed algorithm treats an image as if it were a topographic surface.
The dark areas are basins. The light areas are the ridges around the basins.
The user is responsible for determining the number of output segments and the location of each segment in the input array.
This function supports 8- and 16-bit grayscale and colored images and 24- and 32-bit colored images.
This function does not support 32-bit grayscale images.
This function supports signed/unsigned images.
Watershed Segmentation Function - Before
Watershed Segmentation Function - After
View additional platform support for this Watershed Segmentation function.
Win32, x64.
#if defined (LEADTOOLS_V19_OR_LATER)
L_INT LBitmap__WatershedBitmapExample(L_VOID)
{
L_INT nRet;
LBitmap LeadBitmap;
nRet =LeadBitmap.Load(MAKE_IMAGE_PATH(TEXT("IMAGE3.dcm")), 0,ORDER_BGR);
if(nRet !=SUCCESS)
return nRet ;
/* Apply a WatershedBitmap filter */
L_POINT* ppPoints[4] = {} ;
L_INT Lengths[4] = {} ;
L_INT nSize = 4 ;
for(L_INT i = 0 ; i < nSize; i++)
{
Lengths[i] = 2 ;
ppPoints[i] = (L_POINT*) malloc(Lengths[i]*sizeof(L_POINT));
if ( ppPoints[i] == NULL )
{
for( L_INT j = 0 ; j < nSize ; j++ )
{
if ( ppPoints[j] != NULL )
{
free(ppPoints[j]) ;
}
}
return ERROR_NOT_ENOUGH_MEMORY ;
}
}
ppPoints[0][0].x = 35 ; ppPoints[0][0].y = 100 ;
ppPoints[0][1].x = 35 ; ppPoints[0][1].y = 200 ;
ppPoints[1][0].x = 180 ; ppPoints[1][0].y = 115 ;
ppPoints[1][1].x = 300 ; ppPoints[1][1].y = 115 ;
ppPoints[2][0].x = 235 ; ppPoints[2][0].y = 220 ;
ppPoints[2][1].x = 260 ; ppPoints[2][1].y = 220 ;
ppPoints[3][0].x = 180 ; ppPoints[3][0].y = 330 ;
ppPoints[3][1].x = 350 ; ppPoints[3][1].y = 330 ;
nRet = LeadBitmap.WatershedBitmap(ppPoints, Lengths, nSize);
for( L_INT j = 0 ; j < nSize ; j++ )
{
free(ppPoints[j]) ;
}
return nRet ;
}
#endif // LEADTOOLS_V19_OR_LATER
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