ITK/Examples/Smoothing/AntiAliasBinaryImageFilter: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
No edit summary
(Deprecated content that is moved to sphinx)
 
Line 1: Line 1:
<div class="floatcenter">[[File:ITK_Examples_Baseline_Smoothing_TestAntiAliasBinaryImageFilter.png]]</div>
{{warning|1=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.
==AntiAliasBinaryImageFilter.cxx==
}}
<source lang="cpp">
#include "itkImage.h"
#include "itkImageFileWriter.h"
#include "itkAntiAliasBinaryImageFilter.h"


#include "QuickView.h"
[https://itk.org/ITKExamples[ITK Sphinx Examples]]
 
typedef itk::Image<unsigned char, 2>  UnsignedCharImageType;
typedef itk::Image<float, 2>  FloatImageType;
 
static void CreateImage(UnsignedCharImageType::Pointer image);
 
int main(int, char *[])
{
  UnsignedCharImageType::Pointer image = UnsignedCharImageType::New();
  CreateImage(image);
 
  // Take the absolute value of the image
  typedef itk::AntiAliasBinaryImageFilter <UnsignedCharImageType, FloatImageType>
          AntiAliasBinaryImageFilterType;
 
  AntiAliasBinaryImageFilterType::Pointer antiAliasFilter
          = AntiAliasBinaryImageFilterType::New ();
  antiAliasFilter->SetInput(image);
 
  QuickView viewer;
  viewer.AddImage<UnsignedCharImageType>(image);
  viewer.AddImage<FloatImageType>(antiAliasFilter->GetOutput());
  viewer.Visualize();
 
  return EXIT_SUCCESS;
}
 
void CreateImage(UnsignedCharImageType::Pointer image)
{
  UnsignedCharImageType::IndexType start;
  start.Fill(0);
 
  UnsignedCharImageType::SizeType size;
  size.Fill(200);
 
  UnsignedCharImageType::RegionType region;
  region.SetSize(size);
  region.SetIndex(start);
 
  image->SetRegions(region);
  image->Allocate();
 
  itk::ImageRegionIterator<UnsignedCharImageType> imageIterator(image,region);
 
  while(!imageIterator.IsAtEnd())
    {
    if(imageIterator.GetIndex()[0] - imageIterator.GetIndex()[1] > 5) // some pixels white, some black
      {
      imageIterator.Set(255);
      }
    else
      {
      imageIterator.Set(0);
      }
    ++imageIterator;
    }
 
}
</source>
 
{{ITKVTKCMakeLists|{{SUBPAGENAME}}}}

Latest revision as of 20:04, 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]