Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.10.24
LEADTOOLS Mixed Raster Content (MRC) C DLL Help

L_MrcSegmentBitmap

Show in webframe

#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

Functions:

L_MrcStartBitmapSegmentation, L_MrcStopBitmapSegmentation, L_MrcSetSegmentData, L_MrcDeleteSegment, L_MrcCombineSegments, L_MrcEnumSegments, L_MrcSaveSegmentation, L_MrcLoadSegmentation, L_MrcCopySegmentationHandle

Topics:

Auto-Segmentation

 

MRC Bitmap Functions: Automatic Segmentation

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;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.