Error processing SSI file
LEADTOOLS MRC (Leadtools.Mrc assembly)

Show in webframe

SetSegmentData Method






The image that will be segmented.
ID of the segment to be updated.
Instance of the structure that contains the new segment information.
Updates the specified segment.
Syntax
public void SetSegmentData( 
   RasterImage image,
   int id,
   MrcSegmentData data
)
'Declaration
 
Public Sub SetSegmentData( _
   ByVal image As RasterImage, _
   ByVal id As Integer, _
   ByVal data As MrcSegmentData _
) 
'Usage
 
Dim instance As MrcSegmenter
Dim image As RasterImage
Dim id As Integer
Dim data As MrcSegmentData
 
instance.SetSegmentData(image, id, data)

            

            
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.
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.
Example
Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Mrc

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 LeadRect(0, 0, 60, 60)
      newData.SegmentType = MrcSegmentType.Picture
      'segmenter.SetSegmentData(segmentedImage, iD, newData);
   End If
   Return True
End Function
<TestMethod()> _
Public Sub SetSegmentDataExample()
   ' Load an image
   Dim codecs As RasterCodecs = New RasterCodecs()
   codecs.ThrowExceptionsOnInvalidImages = True

   Dim image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "PDFSegmentation.pdf"))

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

   Dim setSegmentCallBack As MrcEnumerateSegmentsInfo = New MrcEnumerateSegmentsInfo(AddressOf MrcEnumerateSegmentInfoSetSegmentDataCallback)
   segmenter.EnumerateSegments(setSegmentCallBack)
End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Mrc;

private bool MrcEnumerateSegmentInfoSetSegmentDataCallback(MrcSegmenter segmentHandle, MrcSegmentData data, int iD)
{
   if (iD == 0)
   {
      MrcSegmentData newData = data;
      newData.ImageSegment = new LeadRect(0, 0, 60, 60);
      newData.SegmentType = MrcSegmentType.Picture;
      //segmenter.SetSegmentData(segmentedImage, iD, newData);
   }
   return true;
}
[TestMethod]
public void SetSegmentDataExample()
{
   // Load an image
   RasterCodecs codecs = new RasterCodecs();
   codecs.ThrowExceptionsOnInvalidImages = true;

   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "PDFSegmentation.pdf"));

   MrcSegmenter segmenter = new MrcSegmenter(image, RasterColor.FromKnownColor(RasterKnownColor.White), RasterColor.FromKnownColor(RasterKnownColor.Black));

   segmenter.SegmentImage(image, MrcSegmentImageOptions.Empty);

   MrcEnumerateSegmentsInfo setSegmentCallBack = new MrcEnumerateSegmentsInfo(MrcEnumerateSegmentInfoSetSegmentDataCallback);
   segmenter.EnumerateSegments(setSegmentCallBack);
}

static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Requirements

Target Platforms

See Also

Reference

MrcSegmenter Class
MrcSegmenter Members
SegmentImage Method
AddSegment Method
DeleteSegment Method
CombineSegments Method
Clone Method

Error processing SSI file
Leadtools.Mrc requires a Document or Medical toolkit license and unlock key. For more information, refer to: LEADTOOLS Toolkit Features