{
class ThresholdingPixelAccessor
{
public:
using InternalType = unsigned char;
using ExternalType = unsigned char;
ThresholdingPixelAccessor() = default;
ExternalType
Get(const InternalType & input) const
{
return (input > m_Threshold) ? 1 : 0;
}
void
SetThreshold(const InternalType threshold)
{
m_Threshold = threshold;
}
ThresholdingPixelAccessor &
operator=(const ThresholdingPixelAccessor & vpa) = default;
private:
InternalType m_Threshold{ 0 };
};
}
int
main(int argc, char * argv[])
{
if (argc < 4)
{
std::cerr << "Usage: " << std::endl;
std::cerr << "ImageAdaptor4 inputFileName outputBinaryFileName ";
std::cerr << " thresholdValue" << std::endl;
return EXIT_FAILURE;
}
using PixelType = itk::ThresholdingPixelAccessor::InternalType;
using ImageAdaptorType =
auto adaptor = ImageAdaptorType::New();
itk::ThresholdingPixelAccessor accessor;
accessor.SetThreshold(std::stoi(argv[3]));
adaptor->SetPixelAccessor(accessor);
auto reader = ReaderType::New();
reader->SetFileName(argv[1]);
reader->Update();
adaptor->SetImage(reader->GetOutput());
using RescalerType =
auto rescaler = RescalerType::New();
auto writer = WriterType::New();
writer->SetFileName(argv[2]);
rescaler->SetOutputMinimum(0);
rescaler->SetOutputMaximum(255);
rescaler->SetInput(adaptor);
writer->SetInput(rescaler->GetOutput());
writer->Update();
return EXIT_SUCCESS;
}
Give access to partial aspects of voxels from an Image.
Data source that reads image data from a single file.
Writes image data to a single file.
Templated n-dimensional image class.
Applies a linear transformation to the intensity levels of the input Image.
constexpr unsigned int Dimension
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....