ITK/Examples/EdgesAndGradients/ZeroCrossingBasedEdgeDetectionImageFilter: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
(Created page with "The zero-crossing based edge detector looks for pixels in the Laplacian of an image where the value of the Laplacian passes through zero --- points where the Laplacian changes si...")
 
(Deprecated content that is moved to sphinx)
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
The zero-crossing based edge detector looks for pixels in the Laplacian of
{{warning|1=The media wiki content on this page is no longer maintainedThe examples presented on the https://itk.org/Wiki/* pages likely require ITK version 4.13 or earlier releasesIn many cases, the examples on this page no longer conform to the best practices for modern ITK versions.}}
an image where the value of the Laplacian passes through zero --- points
where the Laplacian changes signSuch points often occur at ``edges'' in
images --- i.e. points where the intensity of the image changes rapidly,
but they also occur at places that are not as easy to associate with edges.
 
This example requires an input file and an optional variance.
 
Contributed by: Bill Lorensen
==ITKVTKExample.cxx==
<source lang="cpp">
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkZeroCrossingBasedEdgeDetectionImageFilter.h"
 
#include "itksys/SystemTools.hxx"
 
#include "QuickView.h"
 
int main(int argc, char * argv[])
{
  // Verify command line arguments
  if( argc < 2 )
    {
    std::cerr << "Usage: " << std::endl;
    std::cerr << argv[0] << " inputImageFile" << std::endl;
    return EXIT_FAILURE;
    }
 
  double var = 5.0;
  if (argc > 2)
    {
    var = atof(argv[2]);
    }
 
    // Parse command line arguments
  std::string inputFilename = argv[1];
 
  // Setup types
  typedef itk::Image< float,  2 >                FloatImageType;
  typedef itk::ImageFileReader< FloatImageType > ReaderType;
 
  typedef itk::ZeroCrossingBasedEdgeDetectionImageFilter<
    FloatImageType, FloatImageType >  FilterType;
 
  // Create and setup a reader
  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileName( inputFilename.c_str() );
 
  // Create and setup a derivative filter
  FilterType::Pointer edgeDetector = FilterType::New();
  edgeDetector->SetInput( reader->GetOutput() );
  FilterType::ArrayType variance;
  variance.Fill(var);
   edgeDetector->SetVariance(variance);
 
  QuickView viewer;
  viewer.AddImage(
    reader->GetOutput(),true,
    itksys::SystemTools::GetFilenameName(inputFilename)); 
 
  std::stringstream desc;
  desc << "ZeroBasedEdgeDetection, variance = "
      << edgeDetector->GetVariance();
  viewer.AddImage(
    edgeDetector->GetOutput(),
    true,
    desc.str()); 
 
  viewer.Visualize();
 
  return EXIT_SUCCESS;
}
</source>
{{ITKVTKCMakeLists|{{SUBPAGENAME}}}}

Latest revision as of 16:46, 6 June 2019

Warning: The media wiki content on this page is no longer maintained. The examples presented on the https://itk.org/Wiki/* pages likely require ITK version 4.13 or earlier releases. In many cases, the examples on this page no longer conform to the best practices for modern ITK versions.