Clone Method

Summary
Copies the segmentation object to another segmentation object with its data.
Syntax
C#
C++/CLI
Python
public MrcSegmenter Clone() 
public: 
MrcSegmenter^ Clone();  
def Clone(self): 
Remarks

For more information, refer to Programming with LEADTOOLS MRC.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Mrc; 
 
private MrcSegmenter MrcListSegmentation(RasterImage image) 
{ 
   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; 
 
   RasterColor backColor = new RasterColor(255, 255, 255); 
   RasterColor foreColor = new RasterColor(0, 0, 0); 
 
   MrcSegmenter mrcSegmenter = new MrcSegmenter(image, RasterColor.FromKnownColor(RasterKnownColor.White), RasterColor.FromKnownColor(RasterKnownColor.Black)); 
   mrcSegmenter.SegmentImage(image, segmentImageOptions); 
   return mrcSegmenter; 
} 
 
public void SaveBitmapListExample() 
{ 
   // Load an image 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
   RasterImage image1 = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "MRCSegmentation.mrc")); 
 
   // Load an image 
   RasterImage image2 = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "MRCSegmentation.mrc")); 
 
   MrcSegmenter segmenter1 = MrcListSegmentation(image1); 
   MrcSegmenter segmenter2 = MrcListSegmentation(image2); 
   MrcSegmenter segmenter3 = (MrcSegmenter)segmenter2.Clone(); 
   List<MrcSegmenter> segmenterList = new List<MrcSegmenter>(); 
 
   segmenterList.Add(segmenter1); 
   segmenterList.Add(segmenter2); 
   segmenterList.Add(segmenter3); 
 
   MrcSegmenter[] segmenterArray = new MrcSegmenter[3]; 
 
   segmenterList.CopyTo(segmenterArray, 0); 
 
   List<RasterImage> imageList = new List<RasterImage>(); 
   int index; 
 
   for (index = 0; index < 3; index++) 
   { 
      if (segmenterList.Contains(segmenterArray[index])) 
      { 
         switch (segmenterList.IndexOf(segmenterArray[index])) 
         { 
            case 0: 
               imageList.Add(image1); 
               break; 
            case 1: 
               imageList.Add(image2); 
               break; 
            case 2: 
               // Remove the last segmenter from the segmenter array... 
               segmenterList.Remove(segmenterArray[index]); 
               break; 
         } 
      } 
   } 
   MrcCompressionOptions compressionOptions = new MrcCompressionOptions(); 
 
   compressionOptions.MaskCoder = MrcMaskCompression.FaxG31D; 
   compressionOptions.PictureCoder = MrcPictureCompression.Jpeg; 
   compressionOptions.PictureQualityFactor = 10; 
   compressionOptions.Text2BitCoder = MrcTextCompression2BitCoder.Gif2Bit; 
   compressionOptions.Grayscale2BitCoder = MrcGrayscaleCompression2BitCoder.Jbig2; 
   compressionOptions.Grayscale8BitCoder = MrcGrayscaleCompression8BitCoder.GrayscaleCmw; 
   compressionOptions.Grayscale8BitFactor = 2; 
 
   // Save the two segmenters 
   MrcSegmenter.SaveBitmapList(segmenterList, imageList, Path.Combine(LEAD_VARS.ImagesDir, "SaveBitmapListResult.mrc"), MrcImageListFormat.MrcTif, compressionOptions); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

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.