L_MrcSetSegmentData

#include "ltsgm.h"

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

HSEGMENTATION hSegment;

/* segmentation handle */

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

L_INT nSegId;

/* segment identifier */

pSEGMENTDATA pSegmentData;

/* pointer to a structure */

Updates the specified segment. This function is available in the (Document/Medical) toolkits.

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.

nSegId

ID of the segment to be updated.

pSegmentData

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

Returns

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

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_MrcSegmentBitmap, L_MrcDeleteSegment, L_MrcEnumSegments, L_MrcCombineSegments, L_MrcSaveSegmentation, L_MrcLoadSegmentation, L_MrcCopySegmentationHandle, L_MrcSegmentBitmapExt

Topics:

Auto-Segmentation

 

Manual Segmentation

 

MRC Bitmap Functions: Manipulating Segments

Example

Update segment example.

L_INT EXT_CALLBACK EnumSegmentCallBack(HSEGMENTATION  hSegmentation, const pSEGMENTDATA pSegment, L_INT nSegId, L_VOID L_FAR *pUserData)
{
   L_TCHAR szSegmentRect[256];
   L_TCHAR szSegmentId[256];

   memset(szSegmentRect, 0, 256);
   memset(szSegmentId, 0, 256);

   wsprintf(szSegmentId, TEXT("Segment no %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;
}

L_INT UpdateSegment(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 SUCCESS;
}