LSegment::MrcSegmentBitmapExt

#include "ltwrappr.h"

L_INT LSegment::MrcSegmentBitmapExt(pBitmap, pSegOption)

LBitmapBase * 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. This function is available only in the Document/Medical Toolkits.

Parameter

Description

pBitmap

Pointer to the bitmap object 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

Please note that this function handles background segments and certain text segments that the LSegment::MrcSegmentBitmap function. In addition, the LSegment::MrcSegmentBitmap function will be removed in the next major release of LEADTOOLS and this function will replace it.

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 LSegment::MrcStartBitmapSegmentation function before using any of the segmentation functions. When the LSegment class object is no longer needed, free it by calling the LSegment::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:

LSegment::MrcStartBitmapSegmentation, LSegment::MrcStopBitmapSegmentation, LSegment::MrcSetSegmentData, LSegment::MrcEnumSegments, LSegment::MrcDeleteSegment, LSegment::MrcCombineSegments, LSegment::MrcSaveSegmentation, LSegment::MrcLoadSegmentation, LSegment::MrcCopySegmentationHandle, LSegment::MrcSegmentBitmap, Class Members

Topics:

Auto-Segmentation

 

MRC Bitmap Functions: Automatic Segmentation

Example

class LSegmentChild : public Lsegment
{
   L_INT MrcEnumSegmentsCallBack(const pSEGMENTDATA pSegment, L_INT nSegId)
   {
      L_TCHAR szSegmentRect[256];
      L_TCHAR szSegmentId[256];
      
      memset(szSegmentRect, 0, 256);
      memset(szSegmentId, 0, 256);
      
      wsprintf(szSegmentId, TEXT("Segment ID %d"), nSegId);
      wsprintf(szSegmentRect, TEXT("Left = %d, Top = %d, Right = %d, Bottom = %d"), pSegment->rcBitmapSeg.left,  pSegment->rcBitmapSeg.top, pSegment->rcBitmapSeg.right, pSegment->rcBitmapSeg.bottom);
      
      MessageBox(NULL, szSegmentRect, szSegmentId, MB_OK);
      
      return SUCCESS;
   }
};

void MrcSegmentBitmapExtExample(LBitmap& LeadBitmap)
{
   LSegmentChild segment ;
   SEGMENTEXTOPTIONS SegOpt;
   L_INT nRet = 0 ;
   
   memset(&SegOpt,0,sizeof(SegOpt));
   /* Specify the minimum segment width and height*/
   SegOpt.uStructSize           = sizeof(SegOpt);
   SegOpt.uBackGroundThreshold  = 10;
   SegOpt.uSegmentQuality        = 50;  
   SegOpt.uColorThreshold         = 25;
   SegOpt.uCleanSize              = 5;
   SegOpt.uCombineThreshold     = 75;

   
   /* Start the segmentation process */
   nRet = segment.MrcStartBitmapSegmentation (&LeadBitmap, RGB(255, 255, 255), RGB(0, 0, 0));
   if(nRet == SUCCESS)
   {
      /* do the auto-segmentation*/
      nRet = segment.MrcSegmentBitmapExt(&LeadBitmap, &SegOpt);
      if(nRet == SUCCESS)
      {
         segment.EnableCallBack (TRUE);
         nRet = segment.MrcEnumSegments (0);
         segment.EnableCallBack(FALSE);
         
         /* end the segmentation process */
         nRet = segment.MrcStopBitmapSegmentation ();
      }
   }
}