{
class VectorPixelAccessor
{
public:
using ExternalType = float;
VectorPixelAccessor() = default;
VectorPixelAccessor &
operator=(const VectorPixelAccessor & vpa) = default;
ExternalType
Get(const InternalType & input) const
{
return static_cast<ExternalType>(input[m_Index]);
}
void
SetIndex(unsigned int index)
{
m_Index = index;
}
private:
unsigned int m_Index{ 0 };
};
}
int
main(int argc, char * argv[])
{
if (argc < 4)
{
std::cerr << "Usage: " << std::endl;
std::cerr << "ImageAdaptor3 inputFileName outputComponentFileName ";
std::cerr << " indexOfComponentToExtract" << std::endl;
return EXIT_FAILURE;
}
using InputPixelType = unsigned char;
using GradientFilterType =
VectorImageType>;
auto gradient = GradientFilterType::New();
using ImageAdaptorType =
auto adaptor = ImageAdaptorType::New();
itk::VectorPixelAccessor accessor;
accessor.SetIndex(std::stoi(argv[3]));
adaptor->SetPixelAccessor(accessor);
auto reader = ReaderType::New();
gradient->SetInput(reader->GetOutput());
reader->SetFileName(argv[1]);
gradient->Update();
adaptor->SetImage(gradient->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;
}
A templated class holding a n-Dimensional covariant vector.
Computes the gradient of an image by convolution with the first derivative of a Gaussian.
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....