int
main(int argc, char * argv[])
{
if (argc < 2)
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImageFile " << std::endl;
return EXIT_FAILURE;
}
using PixelType = unsigned char;
constexpr unsigned int Dimension = 2;
auto reader = ReaderType::New();
const char * inputFilename = argv[1];
reader->SetFileName(inputFilename);
try
{
reader->Update();
}
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return EXIT_FAILURE;
}
auto pointSet = PointSetType::New();
const ImageType * image = reader->GetOutput();
IteratorType it(image, image->GetBufferedRegion());
it.GoToBegin();
using PointType = PointSetType::PointType;
PointType point;
unsigned long pointId = 0;
while (!it.IsAtEnd())
{
image->TransformIndexToPhysicalPoint(it.GetIndex(), point);
pointSet->SetPoint(pointId, point);
pointSet->SetPointData(pointId, it.Get());
++it;
++pointId;
}
std::cout << "Number Of Points = ";
std::cout << pointSet->GetNumberOfPoints() << std::endl;
return EXIT_SUCCESS;
}
Standard exception handling object.
Data source that reads image data from a single file.
A multi-dimensional iterator templated over image type that walks a region of pixels.
Templated n-dimensional image class.
A superclass of the N-dimensional mesh structure; supports point (geometric coordinate and attribute)...