[ITK-users] Creating 3D dome using ITK

sidharta sidharta.gupta93 at gmail.com
Wed May 10 13:10:44 EDT 2017


So I tried the following:

int EllipseSpatialObjectToImage(InputImageType::Pointer binaryImage){

	typedef itk::EllipseSpatialObject<Dimension> EllipseType;
	typedef itk::SpatialObjectToImageFilter<EllipseType, InputImageType>
SpatialObjectToImageFilterType;

	SpatialObjectToImageFilterType::Pointer spatialObjectToImageFilter =
		SpatialObjectToImageFilterType::New();

	InputImageType::SizeType size;
	size[0] = 8;
	size[1] = 8;
	size[2] = 8;
	// spatialObjectToImageFilter->SetSize(size); not setting the size
explicitly as by default the filter will calculate the optimum size. 

	InputImageType::SpacingType spacing;
	spacing.Fill(1);
	spatialObjectToImageFilter->SetSpacing(spacing);

	EllipseType::Pointer ellipse = EllipseType::New();
	EllipseType::ArrayType radiusArray;
	ellipse->SetRadius(8);   // Since I want half of this ellipse, I set the
radius to 8.

	// Position the ellipse in the image
	typedef EllipseType::TransformType TransformType;
	TransformType::Pointer transform = TransformType::New();

	transform->SetIdentity();

	TransformType::OutputVectorType translation;
	TransformType::CenterType center;
	translation[0] = 8 * spacing[0]; // Translate so the center of the
"ellipse" is such that it covers the entire image bounds. 
	translation[1] = 8 * spacing[1];
	translation[2] = -8 * spacing[2]; // This is for dome
	transform->Translate(translation);
	ellipse->SetObjectToParentTransform(transform);
	std::cout << "Ellipse bounding box " <<
ellipse->GetBoundingBox()->GetMaximum() << std::endl;
	spatialObjectToImageFilter->SetInput(ellipse);
	ellipse->SetDefaultInsideValue(255);
	ellipse->SetDefaultOutsideValue(0);

	spatialObjectToImageFilter->SetUseObjectValue(true);
	spatialObjectToImageFilter->SetOutsideValue(0);

	spatialObjectToImageFilter->Update();

	int flag = FileWriter(spatialObjectToImageFilter->GetOutput(),
"C:/Users/api/Desktop/dome.mhd");
	if (!flag)
		return EXIT_FAILURE;
	return EXIT_SUCCESS;


}

But I don't get what I am intending. Any suggestions?




--
View this message in context: http://itk-users.7.n7.nabble.com/Creating-3D-dome-using-ITK-tp38201p38220.html
Sent from the ITK - Users mailing list archive at Nabble.com.


More information about the Insight-users mailing list