#include "itkRescaleIntensityImageFilter.h"
int main(
int argc,
char* argv[])
{
if (argc != 12)
{
std::cerr << "Usage: " << argv[0];
std::cerr << "inputFileName outputFileName printableInputFileName printableOutputFileName";
std::cerr << "firstPixelComponent secondPixelComponent thirdPixelComponent fourthPixelComponent ";
std::cerr << "variance ";
std::cerr << "minThreshold maxThreshold " << std::endl;
return EXIT_FAILURE;
}
const unsigned int Dimension = 2;
using InputPixelType = double;
using OutputPixelType = double;
using VectorPixelType = VectorImageType::PixelType;
ReaderType::Pointer reader = ReaderType::New();
CloudDetectionFilterType::Pointer cloudDetection = CloudDetectionFilterType::New();
WriterType::Pointer writer = WriterType::New();
reader->SetFileName(argv[1]);
cloudDetection->SetInput(reader->GetOutput());
VectorPixelType referencePixel;
referencePixel.SetSize(4);
referencePixel.Fill(0.);
referencePixel[0] = (atof(argv[5]));
referencePixel[1] = (atof(argv[6]));
referencePixel[2] = (atof(argv[7]));
referencePixel[3] = (atof(argv[8]));
cloudDetection->SetReferencePixel(referencePixel);
cloudDetection->SetVariance(atof(argv[9]));
cloudDetection->SetMinThreshold(atof(argv[10]));
cloudDetection->SetMaxThreshold(atof(argv[11]));
writer->SetFileName(argv[2]);
writer->SetInput(cloudDetection->GetOutput());
writer->Update();
using RescalerOutputType = itk::RescaleIntensityImageFilter<OutputImageType, OutputPrettyImageType>;
ChannelExtractorType::Pointer selecter = ChannelExtractorType::New();
RescalerInputType::Pointer inputRescaler = RescalerInputType::New();
WriterPrettyInputType::Pointer prettyInputWriter = WriterPrettyInputType::New();
selecter->SetInput(reader->GetOutput());
selecter->SetChannel(3);
selecter->SetChannel(2);
selecter->SetChannel(1);
inputRescaler->SetInput(selecter->GetOutput());
VectorPixelType minimum, maximum;
minimum.SetSize(3);
maximum.SetSize(3);
minimum.Fill(0);
maximum.Fill(255);
inputRescaler->SetOutputMinimum(minimum);
inputRescaler->SetOutputMaximum(maximum);
prettyInputWriter->SetFileName(argv[3]);
prettyInputWriter->SetInput(inputRescaler->GetOutput());
RescalerOutputType::Pointer outputRescaler = RescalerOutputType::New();
WriterPrettyOutputType::Pointer prettyOutputWriter = WriterPrettyOutputType::New();
outputRescaler->SetInput(cloudDetection->GetOutput());
outputRescaler->SetOutputMinimum(0);
outputRescaler->SetOutputMaximum(255);
prettyOutputWriter->SetFileName(argv[4]);
prettyOutputWriter->SetInput(outputRescaler->GetOutput());
prettyInputWriter->Update();
prettyOutputWriter->Update();
return EXIT_SUCCESS;
}