static void CreateImage(RGBImageType* const image);
int main(int argc, char *argv[])
{
RGBImageType::Pointer image;
std::string imageName;
if(argc < 2)
{
image = RGBImageType::New();
CreateImage(image);
imageName = "Generated image";
}
else
{
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(argv[1]);
reader->Update();
image = reader->GetOutput();
imageName = argv[1];
}
LuminanceFilterType::Pointer luminanceFilter = LuminanceFilterType::New();
luminanceFilter->SetInput(image);
luminanceFilter->Update();
image.GetPointer(),
true,
imageName);
luminanceFilter->GetOutput(),
true,
"Luminance");
return EXIT_SUCCESS;
}
void CreateImage(RGBImageType* const image)
{
unsigned int NumRows = 200;
unsigned int NumCols = 300;
size[0] = NumRows;
size[1] = NumCols;
image->SetRegions(region);
image->Allocate();
RGBImageType::PixelType pixel;
pixel.SetRed(200);
pixel.SetGreen(50);
pixel.SetBlue(50);
for(unsigned int r = 40; r < 100; r++)
{
for(unsigned int c = 40; c < 100; c++)
{
pixelIndex[0] = r;
pixelIndex[1] = c;
image->SetPixel(pixelIndex, pixel);
}
}
}