int
main(int argc, char * argv[])
{
if (argc < 2)
{
std::cerr << "Missing arguments" << std::endl;
std::cerr << "Usage: PolyLineParametricPath inputImageFileName"
<< std::endl;
return EXIT_FAILURE;
}
constexpr unsigned int Dimension = 2;
auto reader = ReaderType::New();
reader->SetFileName(argv[1]);
try
{
reader->Update();
}
{
std::cout << "Problem reading the input image " << std::endl;
std::cout << excp << std::endl;
return EXIT_FAILURE;
}
const ImageType::ConstPointer image = reader->GetOutput();
auto path = PathType::New();
using ContinuousIndexType = PathType::ContinuousIndexType;
ContinuousIndexType cindex;
using ImagePointType = ImageType::PointType;
ImagePointType origin = image->GetOrigin();
ImageType::SpacingType spacing = image->GetSpacing();
ImageType::SizeType size = image->GetBufferedRegion().GetSize();
ImagePointType point;
point[0] = origin[0] + spacing[0] * size[0];
point[1] = origin[1] + spacing[1] * size[1];
using ContinuousIndexValueType = ContinuousIndexType::ValueType;
cindex =
image->TransformPhysicalPointToContinuousIndex<ContinuousIndexValueType>(
origin);
path->AddVertex(cindex);
cindex =
image->TransformPhysicalPointToContinuousIndex<ContinuousIndexValueType>(
point);
path->AddVertex(cindex);
return EXIT_SUCCESS;
}
Standard exception handling object.
Data source that reads image data from a single file.
Templated n-dimensional image class.
Represent a path of line segments through ND Space.