MrcEnumerateSegmentsInfo Delegate

Summary
Handles each enumerated segment. This delegate is passed as a parameter to the EnumerateSegments method.
Syntax
C#
C++/CLI
Python
public delegate bool MrcEnumerateSegmentsInfo( 
   MrcSegmenter segmentHandle, 
   MrcSegmentData data, 
   int id 
) 
public delegate bool MrcEnumerateSegmentsInfo(  
   MrcSegmenter^ segmentHandle, 
   MrcSegmentData data, 
   int id 
) 
def MrcEnumerateSegmentsInfo(self,segmentHandle,data,id): 
# segmentHandle : MrcSegmenter, data : MrcSegmentData, id : Int32 

Parameters

segmentHandle
An Instance of MrcSegmenter class.

data
An Instance of MrcSegmentData that you can use to access a variable or structure containing data that your delegate method needs. This gives you a way to receive data indirectly from the method that uses this delegate method.

id
ID of the segment being enumerated.

Remarks

This delegate method is called for each segment enumerated by the EnumerateSegments method. The delegate receives segment data, segment ID and any other associated user data for each segment. This delegate can be used when performing automatic or manual segmentation.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Mrc; 
 
private bool MrcEnumerateSegmentInfoCallback(MrcSegmenter segmentHandle, MrcSegmentData data, int iD) 
{ 
   if (iD == 0) 
   { 
      MessageBox.Show("Segment ID : " + iD.ToString()); 
      MessageBox.Show("Left : " + data.ImageSegment.Left.ToString() + 
         "\nTop : " + data.ImageSegment.Top.ToString() + 
         "\nRight : " + data.ImageSegment.Right.ToString() + 
         "\nBottom : " + data.ImageSegment.Bottom.ToString()); 
   } 
   return true; 
} 
 
public void MrcSegmenterExample() 
{ 
   // Load an image 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "PDFSegmentation.pdf")); 
 
   MrcSegmentImageOptions segmentImageOptions = MrcSegmentImageOptions.Empty; 
   segmentImageOptions.CleanSize = 5; 
   segmentImageOptions.SegmentQuality = 50; 
   segmentImageOptions.ColorThreshold = 25; 
   segmentImageOptions.BackgroundThreshold = 10; 
   segmentImageOptions.CombineThreshold = 75; 
   segmentImageOptions.Flags = MrcSegmentImageFlags.FavorOneBit | MrcSegmentImageFlags.SegmentWithBackground; 
 
   MrcSegmenter segmenter = new MrcSegmenter(image, RasterColor.FromKnownColor(RasterKnownColor.White), RasterColor.FromKnownColor(RasterKnownColor.Black)); 
   segmenter.SegmentImage(image, segmentImageOptions); 
 
   MrcEnumerateSegmentsInfo callBack = new MrcEnumerateSegmentsInfo(MrcEnumerateSegmentInfoCallback); 
   segmenter.EnumerateSegments(callBack); 
 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

See Also

Reference

MrcEnumerateSegmentsInfo Members

Leadtools.Mrc Namespace

Help Version 22.0.2023.4.12
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Mrc Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.