L_MrcSegmentBitmap

Summary

Automatically segments the specified bitmap, finding the best segment combination without specifying minimum segment dimensions.

Syntax

#include "ltsgm.h"

L_LTSGM_API L_INT L_MrcSegmentBitmap (hSegment, pBitmap, pSegOption)

Parameters

HSEGMENTATION hSegment

An existing segmentation handle. This handle is obtained by calling the L_MrcStartBitmapSegmentation function.

pBITMAPHANDLE pBitmap

Pointer to the bitmap handle that references the bitmap to be segmented.

pSEGMENTEXTOPTIONS pSegOption

Pointer to the SEGMENTEXTOPTIONS structure that controls the automatic segmentation process. This cannot be NULL.

Returns

Value Meaning
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

See Also

Functions

Topics

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) 
{ 
	/* Load an pass a 24-bit image */ 
 
   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; 
} 

Help Version 22.0.2022.12.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Mixed Raster Content (MRC) C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.