static void CreateImage(ImageType::Pointer image);
int main(int, char *[])
{
ImageType::Pointer image = ImageType::New();
CreateImage(image);
binaryContourImageFilterType;
binaryContourImageFilterType::Pointer binaryContourFilter
= binaryContourImageFilterType::New ();
binaryContourFilter->SetInput(image);
binaryContourFilter->SetForegroundValue(0);
binaryContourFilter->SetBackgroundValue(255);
binaryContourFilter->Update();
InvertIntensityImageFilterType;
InvertIntensityImageFilterType::Pointer invertIntensityFilter
= InvertIntensityImageFilterType::New();
invertIntensityFilter->SetInput(binaryContourFilter->GetOutput());
invertIntensityFilter->Update();
ImageType::Pointer outerBoundary = ImageType::New();
outerBoundary->Graft(invertIntensityFilter->GetOutput());
binaryContourFilter->SetForegroundValue(255);
binaryContourFilter->SetBackgroundValue(0);
binaryContourFilter->Update();
viewer.
AddImage(outerBoundary.GetPointer());
viewer.
AddImage(binaryContourFilter->GetOutput());
return EXIT_SUCCESS;
}
void CreateImage(ImageType::Pointer image)
{
ImageType::RegionType region(start, size);
image->SetRegions(region);
image->Allocate();
image->FillBuffer(0);
for(unsigned int r = 5; r < 10; r++)
{
for(unsigned int c = 5; c < 10; c++)
{
pixelIndex[0] = r;
pixelIndex[1] = c;
image->SetPixel(pixelIndex, 255);
}
}
}