int
main(int argc, char * argv[])
{
if (argc != 2)
{
std::cerr << "Usage: " << argv[0] << " outputimagefile " << std::endl;
return EXIT_FAILURE;
}
using PixelType = unsigned char;
using SpatialObjectToImageFilterType =
size[0] = 100;
size[1] = 100;
size[2] = 1;
ImageType::SpacingType spacing;
spacing[0] = 100.0 / size[0];
spacing[1] = 100.0 / size[1];
spacing[2] = 1.0;
imageFilter->SetSpacing(spacing);
constexpr unsigned int numberOfPoints = 6;
radial[0] = 0.0;
radial[1] = 0.0;
radial[2] = 0.0;
center[0] = 50.0;
center[1] = 50.0;
center[2] = 0.0;
constexpr double radius = 40.0;
typename PolygonType::PolygonPointType polygonPoint;
for (unsigned int i = 0; i < numberOfPoints; ++i)
{
radial[0] = radius * std::cos(angle);
radial[1] = radius * std::sin(angle);
polygonPoint.SetPositionInObjectSpace(
point);
polygon->GetPoints().push_back(polygonPoint);
}
polygon->SetIsClosed(true);
polygon->Update();
std::cout << "Polygon Perimeter = "
<< polygon->MeasurePerimeterInObjectSpace() << std::endl;
std::cout << "Polygon Area = " << polygon->MeasureAreaInObjectSpace()
<< std::endl;
imageFilter->SetInput(polygon);
writer->SetFileName(argv[1]);
writer->SetInput(imageFilter->GetOutput());
try
{
imageFilter->Update();
writer->Update();
}
catch (const itk::ExceptionObject & excp)
{
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}