ITK  5.0.0
Insight Segmentation and Registration Toolkit
WikiExamples/Smoothing/AntiAliasBinaryImageFilter.cxx
#include "itkImage.h"
#include "QuickView.h"
using UnsignedCharImageType = itk::Image<unsigned char, 2>;
using FloatImageType = itk::Image<float, 2>;
static void CreateImage(UnsignedCharImageType::Pointer image);
int main(int, char *[])
{
UnsignedCharImageType::Pointer image = UnsignedCharImageType::New();
CreateImage(image);
// Take the absolute value of the image
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)
{
start.Fill(0);
size.Fill(200);
region.SetSize(size);
region.SetIndex(start);
image->SetRegions(region);
image->Allocate();
while(!imageIterator.IsAtEnd())
{
if(imageIterator.GetIndex()[0] - imageIterator.GetIndex()[1] > 5) // some pixels white, some black
{
imageIterator.Set(255);
}
else
{
imageIterator.Set(0);
}
++imageIterator;
}
}