Leadtools.Mrc Requires Document/Medical product license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
SetSegmentData Method
See Also  Example
Leadtools.Mrc Namespace > MrcSegmenter Class : SetSegmentData Method



image
The image that will be segmented.
id
ID of the segment to be updated.
data
Instance of the structure that contains the new segment information.
image
The image that will be segmented.
id
ID of the segment to be updated.
data
Instance of the structure that contains the new segment information.
Updates the specified segment.

Syntax

Visual Basic (Declaration) 
Public Sub SetSegmentData( _
   ByVal image As RasterImage, _
   ByVal id As Integer, _
   ByVal data As MrcSegmentData _
) 
Visual Basic (Usage)Copy Code
Dim instance As MrcSegmenter
Dim image As RasterImage
Dim id As Integer
Dim data As MrcSegmentData
 
instance.SetSegmentData(image, id, data)
C# 
public void SetSegmentData( 
   RasterImage image,
   int id,
   MrcSegmentData data
)
C++/CLI 
public:
void SetSegmentData( 
   RasterImage image,
   int id,
   MrcSegmentData data
) 

Parameters

image
The image that will be segmented.
id
ID of the segment to be updated.
data
Instance of the structure that contains the new segment information.

Example

Visual BasicCopy Code
Private segmentedImage As RasterImage
Private Function MrcEnumerateSegmentInfoSetSegmentDataCallback(ByVal segmentHandle As MrcSegmenter, ByVal data As MrcSegmentData, ByVal iD As Integer) As Boolean
    If iD = 0 Then
        Dim newData As MrcSegmentData = data
        newData.ImageSegment = New System.Drawing.Rectangle(0, 0, 60, 60)
        newData.SegmentType = MrcSegmentType.Picture
        'segmenter.SetSegmentData(segmentedImage, iD, newData);
    End If
    Return True
End Function

Public Sub SetSegmentDataExample()
    ' Load an image
    RasterCodecs.Startup()
    Dim codecs As RasterCodecs = New RasterCodecs()
    codecs.ThrowExceptionsOnInvalidImages = True

    Dim image As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "Master.jpg")

    Dim segmenter As MrcSegmenter = New MrcSegmenter(image, Color.White, Color.Black)
    segmenter.SegmentImage(image, MrcSegmentImageOptions.Empty)

    Dim setSegmentCallBack As MrcEnumerateSegmentsInfo = New MrcEnumerateSegmentsInfo(AddressOf MrcEnumerateSegmentInfoSetSegmentDataCallback)
    segmenter.EnumerateSegments(setSegmentCallBack)
End Sub
C#Copy Code
private bool MrcEnumerateSegmentInfoSetSegmentDataCallback(MrcSegmenter segmentHandle, MrcSegmentData data, int iD) 

   if (iD == 0) 
   { 
      MrcSegmentData newData = data; 
      newData.ImageSegment = new System.Drawing.Rectangle(0, 0, 60, 60); 
      newData.SegmentType = MrcSegmentType.Picture; 
      //segmenter.SetSegmentData(segmentedImage, iD, newData); 
   } 
   return true; 

 
public void SetSegmentDataExample() 

   // Load an image 
   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   RasterImage image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "Master.jpg"); 
 
   MrcSegmenter segmenter = new MrcSegmenter(image, Color.White, Color.Black); 
   segmenter.SegmentImage(image, MrcSegmentImageOptions.Empty); 
 
   MrcEnumerateSegmentsInfo setSegmentCallBack = new MrcEnumerateSegmentsInfo(MrcEnumerateSegmentInfoSetSegmentDataCallback); 
   segmenter.EnumerateSegments(setSegmentCallBack); 
}

Remarks

This method is used to update the segment information.
In the auto segmentation mode, the LEADTOOLS engine will update the segments using the new segment data passed to this method. This process may create or delete segments. The method will update the segments so they remain within the image width and height.
In the manual segmentation mode, the user is free to update the segments. The LEAD engine will not delete or create segments. If an error occurs, the data parameter will be updated with the target segment.
To get segment IDs and segment information, the user can enumerate all segments using the EnumerateSegments method.
The method will return an error if the updated segment exceeds its image boundaries. For more information, refer to Programming with LEADTOOLS MRC.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Leadtools.Mrc requires a Document or Medical toolkit license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features