#include "itkScalarToRGBColormapImageFilter.h"
int main(
int argc,
char* argv[])
{
if (argc < 9)
{
std::cout << argv[0] << " <output_filename> <Longitude Output Origin point>";
std::cout << " <Latitude Output Origin point> <X Output Size> <Y Output size>";
std::cout << " <X Spacing> <Y Spacing> <DEM folder path>" << std::endl;
return EXIT_FAILURE;
}
using PixelType = double;
using UCharPixelType = unsigned char;
using RGBPixelType = itk::RGBPixel<UCharPixelType>;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(argv[1]);
DEMToImageGeneratorType::Pointer demToImage = DEMToImageGeneratorType::New();
using SizeType = DEMToImageGeneratorType::SizeType;
using SpacingType = DEMToImageGeneratorType::SpacingType;
using PointType = DEMToImageGeneratorType::PointType;
PointType origin;
origin[0] = ::atof(argv[2]);
origin[1] = ::atof(argv[3]);
demToImage->SetOutputOrigin(origin);
SizeType size;
size[0] = ::atoi(argv[4]);
size[1] = ::atoi(argv[5]);
demToImage->SetOutputSize(size);
SpacingType spacing;
spacing[0] = ::atof(argv[6]);
spacing[1] = ::atof(argv[7]);
demToImage->SetOutputSpacing(spacing);
using ColorMapFilterType = itk::ScalarToRGBColormapImageFilter<ImageType, RGBImageType>;
ColorMapFilterType::Pointer colormapper = ColorMapFilterType::New();
colormapper->UseInputImageExtremaForScalingOff();
if (argc == 9)
{
ColorMapFunctorType::Pointer colormap = ColorMapFunctorType::New();
colormap->SetMinimumInputValue(0);
colormap->SetMaximumInputValue(4000);
colormapper->SetColormap(colormap);
}
else
{
if (strcmp(argv[9], "hot") == 0)
{
using ColorMapFunctorType = itk::Function::HotColormapFunction<PixelType, RGBPixelType>;
ColorMapFunctorType::Pointer colormap = ColorMapFunctorType::New();
colormap->SetMinimumInputValue(0);
colormap->SetMaximumInputValue(4000);
colormapper->SetColormap(colormap);
}
else
{
ColorMapFunctorType::Pointer colormap = ColorMapFunctorType::New();
colormap->SetMinimumInputValue(0);
colormap->SetMaximumInputValue(4000);
colormapper->SetColormap(colormap);
}
}
colormapper->SetInput(demToImage->GetOutput());
writer->SetInput(colormapper->GetOutput());
writer->Update();
}