ITK/Examples/EdgesAndGradients/SobelEdgeDetectionImageFilter: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
(Created page with "Error: itkSobelEdgeDetectionImageFilter.txx:129: error: no matching function for call to ‘itk::NeighborhoodOperatorImageFilter<itk::Image<unsigned char, 2u>, itk::Image<float,...")
 
(Deprecated content that is moved to sphinx)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Error:
{{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 releases.   In many cases, the examples on this page no longer conform to the best practices for modern ITK versions.
itkSobelEdgeDetectionImageFilter.txx:129: error: no matching function for call to ‘itk::NeighborhoodOperatorImageFilter<itk::Image<unsigned char, 2u>, itk::Image<float, 2u>, float>::OverrideBoundaryCondition(itk::ZeroFluxNeumannBoundaryCondition<itk::Image<float, 2u> >*)’
}}
  itkNeighborhoodOperatorImageFilter.h:117: note: candidates are: void itk::NeighborhoodOperatorImageFilter<TInputImage, TOutputImage,  TOperatorValueType>::OverrideBoundaryCondition(itk::ImageBoundaryCondition<TImage>*) [with TInputImage = itk::Image<unsigned char, 2u>, TOutputImage = itk::Image<float, 2u>,  TOperatorValueType = float]


 
[https://itk.org/ITKExamples[ITK Sphinx Examples]]
==SobelEdgeDetectionImageFilter.cxx==
<source lang="cpp">
#include "itkImage.h"
#include "itkImageFileWriter.h"
#include "itkSobelEdgeDetectionImageFilter.h"
#include "itkRescaleIntensityImageFilter.h"
 
typedef itk::Image<unsigned char, 2>  UnsignedCharImageType;
typedef itk::Image<float, 2>  FloatImageType;
 
static void CreateImage(UnsignedCharImageType::Pointer);
 
int main(int argc, char *argv[])
{
  UnsignedCharImageType::Pointer image = UnsignedCharImageType::New();
 
  typedef itk::SobelEdgeDetectionImageFilter <UnsignedCharImageType, FloatImageType>
          SobelEdgeDetectionImageFilterType;
  SobelEdgeDetectionImageFilterType::Pointer sobelFilter
          = SobelEdgeDetectionImageFilterType::New();
  sobelFilter->SetInput(image);
  sobelFilter->Update();
 
  typedef itk::RescaleIntensityImageFilter< FloatImageType, UnsignedCharImageType > RescaleFilterType;
  RescaleFilterType::Pointer rescaleFilter = RescaleFilterType::New();
  rescaleFilter->SetInput(sobelFilter->GetOutput());
  rescaleFilter->SetOutputMinimum(0);
  rescaleFilter->SetOutputMaximum(255);
  rescaleFilter->Update();
 
  typedef  itk::ImageFileWriter< UnsignedCharImageType  > WriterType;
  WriterType::Pointer writer = WriterType::New();
  writer->SetFileName("output.png");
  writer->SetInput(rescaleFilter->GetOutput());
  writer->Update();
 
  return EXIT_SUCCESS;
}
 
void CreateImage(UnsignedCharImageType::Pointer image)
{
  itk::Index<2> start;
  start.Fill(0);
 
  itk::Size<2> size;
  size.Fill(100);
 
  itk::ImageRegion<2> region(start, size);
  image->SetRegions(region);
  image->Allocate();
 
  // Make a square
  for(unsigned int r = 20; r < 80; r++)
    {
    for(unsigned int c = 20; c < 80; c++)
      {
      itk::Index<2> pixelIndex;
      pixelIndex[0] = r;
      pixelIndex[1] = c;
 
      image->SetPixel(pixelIndex, 15);
      }
    }
}
</source>
 
{{ITKCMakeLists|SobelEdgeDetectionImageFilter}}

Latest revision as of 16:05, 31 May 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.

[ITK Sphinx Examples]