class RedChannelPixelAccessor
{
public:
using ExternalType = float;
static ExternalType
Get(const InternalType & input)
{
return static_cast<ExternalType>(input.GetRed());
}
};
int
main(int argc, char * argv[])
{
if (argc < 3)
{
std::cerr << "Usage: " << std::endl;
std::cerr << "ImageAdaptor2 inputRGBFileName outputRedChannelFileName"
<< std::endl;
return EXIT_FAILURE;
}
using InputPixelType = RedChannelPixelAccessor::InternalType;
using ImageAdaptorType =
reader->SetFileName(argv[1]);
reader->Update();
adaptor->SetImage(reader->GetOutput());
using RescalerType =
writer->SetFileName(argv[2]);
rescaler->SetOutputMinimum(0);
rescaler->SetOutputMaximum(255);
rescaler->SetInput(adaptor);
writer->SetInput(rescaler->GetOutput());
try
{
writer->Update();
}
catch (const itk::ExceptionObject & excp)
{
std::cerr << "Exception caught " << excp << std::endl;
return EXIT_FAILURE;
}
class GreenChannelPixelAccessor
{
public:
using ExternalType = float;
static ExternalType
Get(const InternalType & input)
{
return static_cast<ExternalType>(input.GetGreen());
}
};
class BlueChannelPixelAccessor
{
public:
using ExternalType = float;
static ExternalType
Get(const InternalType & input)
{
return static_cast<ExternalType>(input.GetBlue());
}
};
return EXIT_SUCCESS;
}