int
main(int argc, char * argv[])
{
if (argc != 2)
{
std::cerr << "Usage: " << argv[0] << " outputimagefile " << std::endl;
return EXIT_FAILURE;
}
using PixelType = short;
using SpatialObjectToImageFilterType =
size[0] = 50;
size[1] = 50;
size[2] = 150;
ImageType::SpacingType spacing;
spacing[0] = 100.0 / size[0];
spacing[1] = 100.0 / size[1];
spacing[2] = 300.0 / size[2];
imageFilter->SetSpacing(spacing);
ellipse->SetRadiusInObjectSpace(size[0] * 0.2 * spacing[0]);
typename TubeType::TubePointType tubePoint;
typename TubeType::TubePointListType tubePointList;
point[0] = size[0] * 0.2 * spacing[0];
point[1] = size[1] * 0.2 * spacing[1];
point[2] = size[2] * 0.2 * spacing[2];
tubePoint.SetPositionInObjectSpace(
point);
tubePoint.SetRadiusInObjectSpace(size[0] * 0.05 * spacing[0]);
tubePointList.push_back(tubePoint);
point[0] = size[0] * 0.8 * spacing[0];
point[1] = size[1] * 0.2 * spacing[1];
point[2] = size[2] * 0.2 * spacing[2];
tubePoint.SetPositionInObjectSpace(
point);
tubePoint.SetRadiusInObjectSpace(size[0] * 0.05 * spacing[0]);
tubePointList.push_back(tubePoint);
tube1->SetPoints(tubePointList);
tubePointList.clear();
point[0] = size[0] * 0.2 * spacing[0];
point[1] = size[1] * 0.8 * spacing[1];
point[2] = size[2] * 0.2 * spacing[2];
tubePoint.SetPositionInObjectSpace(
point);
tubePoint.SetRadiusInObjectSpace(size[0] * 0.05 * spacing[0]);
tubePointList.push_back(tubePoint);
point[0] = size[0] * 0.8 * spacing[0];
point[1] = size[1] * 0.8 * spacing[1];
point[2] = size[2] * 0.8 * spacing[1];
tubePoint.SetPositionInObjectSpace(
point);
tubePoint.SetRadiusInObjectSpace(size[0] * 0.05 * spacing[0]);
tubePointList.push_back(tubePoint);
tube2->SetPoints(tubePointList);
using TransformType = GroupType::TransformType;
transform1->SetIdentity();
transform2->SetIdentity();
transform3->SetIdentity();
TransformType::OutputVectorType translation;
translation[0] = size[0] * spacing[0] / 2.0;
translation[1] = size[1] * spacing[1] / 4.0;
translation[2] = size[2] * spacing[2] / 2.0;
transform1->Translate(translation, false);
translation[1] = size[1] * spacing[1] / 2.0;
translation[2] = size[2] * spacing[2] * 0.22;
transform2->Translate(translation, false);
translation[2] = size[2] * spacing[2] * 0.78;
transform3->Translate(translation, false);
ellipse->SetObjectToParentTransform(transform1);
tube1->SetObjectToParentTransform(transform2);
tube2->SetObjectToParentTransform(transform3);
group->AddChild(ellipse);
group->AddChild(tube1);
group->AddChild(tube2);
ellipse->Update();
tube1->Update();
tube2->Update();
imageFilter->SetInput(group);
constexpr PixelType airHounsfieldUnits = -1000;
constexpr PixelType boneHounsfieldUnits = 800;
ellipse->SetDefaultInsideValue(boneHounsfieldUnits);
tube1->SetDefaultInsideValue(boneHounsfieldUnits);
tube2->SetDefaultInsideValue(boneHounsfieldUnits);
ellipse->SetDefaultOutsideValue(airHounsfieldUnits);
tube1->SetDefaultOutsideValue(airHounsfieldUnits);
tube2->SetDefaultOutsideValue(airHounsfieldUnits);
imageFilter->SetUseObjectValue(true);
imageFilter->SetOutsideValue(airHounsfieldUnits);
writer->SetFileName(argv[1]);
writer->SetInput(imageFilter->GetOutput());
try
{
imageFilter->Update();
writer->Update();
}
{
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
Standard exception handling object.
Representation of a group based on the spatial object classes.
Writes image data to a single file.
Templated n-dimensional image class.
Base class for filters that take a SpatialObject as input and produce an image as output....
Representation of a tube based on the spatial object classes.
constexpr unsigned int Dimension
ImageBaseType::PointType PointType
ImageBaseType::SizeType SizeType
static constexpr double pi
*par Constraints *The filter image with at least two dimensions and a vector *length of at least The theory supports extension to scalar but *the implementation of the itk vector classes do not **The template parameter TRealType must be floating point(float or double) or *a user-defined "real" numerical type with arithmetic operations defined *sufficient to compute derivatives. **\par Performance *This filter will automatically multithread if run with *SetUsePrincipleComponents
void SetSize(const SizeValueType val[VDimension])