L_MrcSetSegmentData

Summary

Updates the specified segment.

Syntax

#include "ltsgm.h"

L_LTSGM_API L_INT L_MrcSetSegmentData(hSegment, pBitmap, nSegId, pSegmentData)

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.

L_INT nSegId

ID of the segment to be updated.

pSEGMENTDATA pSegmentData

Pointer to the SEGMENTDATA structure that contains the new segment information.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

Use this function to update the segment information. In the automatic segmentation mode, the LEADTOOLS engine will update the segments using the new segment data passed to this function. This process may create or delete segments. The function will update the segments so they remain within the bitmap width and height.

In the manual segmentation mode, the user is free to update the segments. The LEADTOOLS engine will not delete or create segments. If an error occurs, the pSegmentData parameter will be updated with the target segment.

To get segment IDs and segment information, use the L_MrcEnumSegments function to enumerate all segments.

The function will return an error if the updated segment exceeds its image boundaries.

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

Update segment example.

L_INT EXT_CALLBACK EnumSegmentCallBack(HSEGMENTATION        hSegmentation, 
                                       const pSEGMENTDATA   pSegment, 
                                       L_INT                nSegId, 
                                       L_VOID*              pUserData) 
{ 
   UNREFERENCED_PARAMETER(hSegmentation); 
   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 MrcSetSegmentDataExample(HSEGMENTATION hSegmentation, 
                                               pBITMAPHANDLE pBitmap, 
                                               pSEGMENTDATA  pNewSegmentData, 
                                               L_INT         nSegId) 
{ 
    L_INT nRet; 
 
  /* update the segments based on the new segment */ 
   nRet = L_MrcSetSegmentData (hSegmentation, pBitmap, nSegId, pNewSegmentData); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   /* Enumerate the new segments and their id's */ 
   L_MrcEnumSegments (hSegmentation, (pMRCENUMSEGMENTSPROC)&EnumSegmentCallBack, NULL, 0); 
 
   /* Delete a segment */ 
   nRet = L_MrcDeleteSegment (hSegmentation, nSegId); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   /* Enumerate the new segments and their id's */ 
   L_MrcEnumSegments(hSegmentation, (pMRCENUMSEGMENTSPROC)&EnumSegmentCallBack, NULL, 0); 
    
 
   return nRet; 
} 

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 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.