2D/3D/4D CPU/GPU bilateral filter based on ITK and OpenCV
The filter only supports grayscale images.
#include <itkImageFileReader.h>
#include <itkImageFileWriter.h>
#include "itkOpenCVBasedBilateralImageFilter.h"
const unsigned int Dimension = 3U;
using PixelType = signed short;
using ImageType = itk::Image<PixelType, Dimension>;
auto reader = itk::ImageFileReader<ImageType>::New();
reader->SetFileName("your_image_3d.nrrd");
auto bilateral = itk::OpenCVBasedBilateralImageFilter<ImageType>::New();
bilateral->SetRangeSigma(15);
bilateral->SetDomainSigma(5);
bilateral->SetInput(reader->GetOutput());
auto writer = itk::ImageFileWriter<ImageType>::New();
writer->SetFileName("your_image_3d_bf.nrrd");
writer->SetInput(bilateral->GetOutput());
try {
writer->Update();
}
catch (itk::ExceptionObject & err) {
std::cerr << err << std::endl;
throw;
}
Brain CT axial slice | Result with rs=30, ds=4 | Second pass with rs=8, ds=2 (removing artifacts) |
---|---|---|