static void CreateImage(UnsignedCharImageType::Pointer image);
int main(int, char *[])
{
UnsignedCharImageType::Pointer image = UnsignedCharImageType::New();
CreateImage(image);
LabelImageToLabelMapFilterType::Pointer labelImageToLabelMapFilter = LabelImageToLabelMapFilterType::New();
labelImageToLabelMapFilter->SetInput(image);
labelImageToLabelMapFilter->Update();
ConnectedComponentImageFilterType::Pointer connectedComponentImageFilter
= ConnectedComponentImageFilterType::New();
ObjectByObjectLabelMapFilterType::Pointer objectByObjectLabelMapFilter = ObjectByObjectLabelMapFilterType::New();
objectByObjectLabelMapFilter->SetInput( labelImageToLabelMapFilter->GetOutput() );
objectByObjectLabelMapFilter->SetBinaryInternalOutput(false);
objectByObjectLabelMapFilter->SetFilter(connectedComponentImageFilter);
objectByObjectLabelMapFilter->Update();
LabelMapToLabelImageFilterType::Pointer labelMapToLabelImageFilter = LabelMapToLabelImageFilterType::New();
labelMapToLabelImageFilter->SetInput(objectByObjectLabelMapFilter->GetOutput());
labelMapToLabelImageFilter->Update();
RGBFilterType::Pointer colormapImageFilter = RGBFilterType::New();
colormapImageFilter->SetInput(labelMapToLabelImageFilter->GetOutput());
colormapImageFilter->SetColormap( RGBFilterType::Jet );
colormapImageFilter->Update();
WriterType::Pointer writer = WriterType::New();
writer->SetInput( colormapImageFilter->GetOutput() );
writer->SetFileName("output.png");
writer->Update();
return EXIT_SUCCESS;
}
void CreateImage(UnsignedCharImageType::Pointer image)
{
image->SetRegions(region);
image->Allocate();
while(!imageIterator.IsAtEnd())
{
if(((imageIterator.GetIndex()[0] > 5 && imageIterator.GetIndex()[0] < 20) &&
(imageIterator.GetIndex()[1] > 5 && imageIterator.GetIndex()[1] < 20)) ||
((imageIterator.GetIndex()[0] > 50 && imageIterator.GetIndex()[0] < 60) &&
(imageIterator.GetIndex()[1] > 50 && imageIterator.GetIndex()[1] < 60)) )
{
}
else if(((imageIterator.GetIndex()[0] > 100 && imageIterator.GetIndex()[0] < 130) &&
(imageIterator.GetIndex()[1] > 100 && imageIterator.GetIndex()[1] < 130)))
{
imageIterator.Set(20);
}
else
{
imageIterator.Set(0);
}
++imageIterator;
}
RGBFilterType::Pointer colormapImageFilter = RGBFilterType::New();
colormapImageFilter->SetInput(image);
colormapImageFilter->SetColormap( RGBFilterType::Jet );
colormapImageFilter->Update();
WriterType::Pointer writer = WriterType::New();
writer->SetFileName("input.png");
writer->SetInput(colormapImageFilter->GetOutput());
writer->Update();
}