←Select platform

GWireCommand Class

Summary
Performs semi-automatic segmentation by creating minimal paths that follow the boundaries of the objects in the image.
Syntax
C#
C++/CLI
Python
public class GWireCommand : IDisposable 
public ref class GWireCommand : public System.IDisposable   
class GWireCommand(IDisposable): 
Remarks
  • This command is useful when extracting objects from an image. It works by constructing a minimal path between two input points (the seed and the target points) that follows the edges of the image's objects.
  • The returned minimal paths can be used to create a region that covers the object of interest.
  • If the image contains a region the region is ignored. The GWireCommand works on the entire image.
  • This function supports 12- and 16-bit grayscale and 48- and 64-bit color images. (Support for 12- and 16-bit grayscale and 48- and 64-bit color images is only available in the Document/Medical Imaging toolkits.)
  • This command does not support signed images.

Gwire Tool Function - Before

Gwire Tool Function - Before

Gwire Tool Function - After

Gwire Tool Function - After

View additional platform support for this Gwire Tool function.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing.Core; 
 
public void GWireCommandExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   //Load an image 
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE3.dcm")); 
 
   GWireCommand command = new GWireCommand(image, 90); 
 
   List<LeadPoint> SeedPoints = new List<LeadPoint>(); 
 
   // Get the boundaries of the object 
   SeedPoints.Add(new LeadPoint(200, 163)); 
   SeedPoints.Add(new LeadPoint(245, 195)); 
   SeedPoints.Add(new LeadPoint(289, 163)); 
   SeedPoints.Add(new LeadPoint(282, 188)); 
   SeedPoints.Add(new LeadPoint(304, 314)); 
   SeedPoints.Add(new LeadPoint(247, 271)); 
   SeedPoints.Add(new LeadPoint(201, 315)); 
   SeedPoints.Add(new LeadPoint(228, 199)); 
   SeedPoints.Add(new LeadPoint(199, 175)); 
 
   int pointIdx = 0; 
   List<LeadPoint> AllPaths = new List<LeadPoint>(); 
 
   // Loop over the list of SeedPoints to get the minimum path between each set of two points. 
   // And add the minimum path between the two points to the AllPaths List. 
   for (int index = 0; index < 4; index++) 
   { 
      // Set the seed point. 
      command.SetSeedPoint(SeedPoints[pointIdx]); 
 
      pointIdx++; 
      // Get the minimum path from the seed point to the target point. 
      LeadPoint[] minPath = command.GetMinPath(SeedPoints[pointIdx]); 
 
      // Add the minimum path to the AllPaths list to be used later to create a region. 
      AllPaths.AddRange(minPath); 
   } 
 
   // Use the minimum path around the object and convert it to a region. 
   image.AddPolygonToRegion(null, AllPaths.ToArray(), LeadFillMode.Alternate, RasterRegionCombineMode.Set); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
Requirements

Target Platforms

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

Leadtools.ImageProcessing.Core Assembly

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