LEADTOOLS MRC (Leadtools.Mrc assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.30
MrcSegmenter Class
See Also  Members  
Leadtools.Mrc Namespace : MrcSegmenter Class



The MrcSegmenter Class is available in LEADTOOLS Document and Medical Imaging toolkits.

MrcSegmenter represents the main class that contains all methods needed to perform a full segmentation process.

Object Model

MrcSegmenter Class

Syntax

Visual Basic (Declaration) 
Public Class MrcSegmenter 
   Implements IDisposable 
Visual Basic (Usage)Copy Code
Dim instance As MrcSegmenter
C# 
public class MrcSegmenter : IDisposable  
C++/CLI 
public ref class MrcSegmenter : public IDisposable  

Example

Visual BasicCopy Code
Private Function MrcEnumerateSegmentInfoCallback(ByVal segmentHandle As MrcSegmenter, ByVal data As MrcSegmentData, ByVal iD As Integer) As Boolean
      Dim segmentRectangle As LeadRect = data.ImageSegment
      If iD = 0 Then
         MessageBox.Show("Segment ID : " & iD.ToString())
         MessageBox.Show("Left : " & segmentRectangle.Left.ToString() & Constants.vbLf & "Top : " & segmentRectangle.Top.ToString() & Constants.vbLf & "Right : " & segmentRectangle.Right.ToString() & Constants.vbLf & "Bottom : " & segmentRectangle.Bottom.ToString())
      End If
      Return True
   End Function

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

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

      Dim segmentImageOptions As MrcSegmentImageOptions = MrcSegmentImageOptions.Empty
      segmentImageOptions.CleanSize = 5
      segmentImageOptions.SegmentQuality = 50
      segmentImageOptions.ColorThreshold = 25
      segmentImageOptions.BackgroundThreshold = 10
      segmentImageOptions.CombineThreshold = 75
      segmentImageOptions.Flags = MrcSegmentImageFlags.FavorOneBit Or MrcSegmentImageFlags.SegmentWithBackground

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

      Dim callBack As MrcEnumerateSegmentsInfo = New MrcEnumerateSegmentsInfo(AddressOf MrcEnumerateSegmentInfoCallback)
      segmenter.EnumerateSegments(callBack)

   End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
C#Copy Code
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,"Master.jpg"));

      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:\Users\Public\Documents\LEADTOOLS Images";
}

Remarks

This class is available in the Document/Medical Toolkits.

Inheritance Hierarchy

System.Object
   Leadtools.Mrc.MrcSegmenter

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7

See Also

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