#include "itksys/SystemTools.hxx"
#include <sstream>
static void CreateImage(ImageType::Pointer image);
int main(int argc, char *argv[])
{
ImageType::Pointer image = ImageType::New();
if (argc < 2)
{
CreateImage(image);
}
else
{
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(argv[1]);
reader->Update();
image = reader->GetOutput();
}
FilterType::Pointer filter = FilterType::New();
filter->SetInput(image);
filter->SetBackgroundValue(0);
filter->SetForegroundValue(255);
image.GetPointer(),true,
argc > 1 ? itksys::SystemTools::GetFilenameName(argv[1]) : "Generated image");
std::stringstream desc;
desc << "Zero Crossing";
filter->GetOutput(),
true,
desc.str());
return EXIT_SUCCESS;
}
void CreateImage(ImageType::Pointer image)
{
image->SetRegions(region);
image->Allocate();
image->FillBuffer(-1);
for(unsigned int i = 0; i < 100; ++i)
{
for(unsigned int j = 0; j < 50; ++j)
{
index[0] = i;
index[1] = j;
image->SetPixel(index, 1);
}
}
}