ITK/Examples/Smoothing/AntiAliasBinaryImageFilter: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
(Created page with "==AntiAliasBinaryImageFilter.cxx== <source lang="cpp"> #include "itkImage.h" #include "itkImageFileWriter.h" #include "itkAntiAliasBinaryImageFilter.h" #include "QuickView.h" t...")
 
(Deprecated content that is moved to sphinx)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
==AntiAliasBinaryImageFilter.cxx==
{{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.
<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>
 
==CMakeLists.txt==
<source lang="cmake">
cmake_minimum_required(VERSION 2.6)
 
PROJECT(AntiAliasBinaryImageFilter)
 
include_directories(/home/doriad/src/ITK/Wrapping/WrapITK/ExternalProjects/ItkVtkGlue/src/)
include_directories(/home/doriad/itkwikiexamples/ItkVtkGlue)
 
FIND_PACKAGE(VTK REQUIRED)
INCLUDE(${VTK_USE_FILE})
FIND_PACKAGE(ITK REQUIRED)
INCLUDE(${ITK_USE_FILE})
 
ADD_EXECUTABLE(AntiAliasBinaryImageFilter AntiAliasBinaryImageFilter.cxx /home/doriad/itkwikiexamples/ItkVtkGlue/QuickView.cxx)
TARGET_LINK_LIBRARIES(AntiAliasBinaryImageFilter vtkHybrid ITKBasicFilters ITKIO)
 
</source>

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]