LEADTOOLS Mixed Raster Content (MRC) C DLL Help > Function References > L_MrcSegmentBitmap |
#include "ltsgm.h"
L_LTSGM_API L_INT L_MrcSegmentBitmap (hSegment, pBitmap, pSegOption)
HSEGMENTATION hSegment; |
/* segmentation handle */ |
pBITMAPHANDLE pBitmap; |
/* pointer to a bitmap handle */ |
pSEGMENTEXTOPTIONS pSegOption; |
/* pointer to a structure */ |
Automatically segments the specified bitmap, finding the best segment combination without specifying minimum segment dimensions.
Parameter |
Description |
hSegment |
An existing segmentation handle. This handle is obtained by calling the L_MrcStartBitmapSegmentation function. |
pBitmap |
Pointer to the bitmap handle that references the bitmap to be segmented. |
pSegOption |
Pointer to the SEGMENTEXTOPTIONS structure that controls the automatic segmentation process. This cannot be NULL. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
Call this function to segment the bitmap automatically. LEAD will process the bitmap and break it into appropriate picture, grayscale, text and background segments.
Call the L_MrcStartBitmapSegmentation function before using any of the segmentation functions. When the handle to the segmentation is no longer needed, free it by calling the L_MrcStopBitmapSegmentation function.
Required DLLs and Libraries
LTSGM For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
See Also
Example
The following example loads a bitmap and then performs automatic segmentation using the L_MrcSegmentBitmap function.
/* pMRCENUMSEGMENTSPROC callback function */ static L_INT EXT_CALLBACK EnumAutoSegments (HSEGMENTATION hSegment, const pSEGMENTDATA pSegment, L_INT nSegId, L_VOID* pUserData) { UNREFERENCED_PARAMETER(hSegment); UNREFERENCED_PARAMETER(pUserData); L_UINT SegArea; L_TCHAR szSegmentId[256]; memset(szSegmentId, 0, 256); wsprintf(szSegmentId, TEXT("Error Segment size in Segment %d"), nSegId); SegArea = (pSegment->rcBitmapSeg.bottom - pSegment->rcBitmapSeg.top) * (pSegment->rcBitmapSeg.right - pSegment->rcBitmapSeg.left); if(SegArea == 0) MessageBox(NULL, szSegmentId, TEXT("Error"), MB_OK); return SUCCESS; } L_INT MrcSegmentBitmapExample(pBITMAPHANDLE pBitmap) { HSEGMENTATION hSegmentation; SEGMENTEXTOPTIONS SegExtOption; L_INT nRet; /* Specify the minimum segment width and height*/ SegExtOption.uStructSize = sizeof(SEGMENTEXTOPTIONS); SegExtOption.uBackGroundThreshold = 10; SegExtOption.uSegmentQuality = 50; SegExtOption.uColorThreshold = 25; SegExtOption.uCleanSize = 5; SegExtOption.uCombineThreshold = 75; SegExtOption.uFlags = SGM_WITHOUTBKGRND | SGM_FAVOR_TWOBIT ; /* Start the segmentation process */ nRet = L_MrcStartBitmapSegmentation (&hSegmentation, pBitmap, RGB(255, 255, 255), RGB(0, 0, 0)); if (nRet != SUCCESS) return nRet; /* do the auto-segmentation*/ nRet = L_MrcSegmentBitmap(hSegmentation, pBitmap, &SegExtOption); if (nRet != SUCCESS) return nRet; L_MrcEnumSegments(hSegmentation, (pMRCENUMSEGMENTSPROC)&EnumAutoSegments, NULL, 0); /* end the segmentation process */ nRet = L_MrcStopBitmapSegmentation(hSegmentation); if (nRet != SUCCESS) return nRet; return SUCCESS; }