int main(int, char *[])
{
ImageType::Pointer image = ImageType::New();
const ImageType::SizeType size = {{ 200, 200, 200}};
const ImageType::IndexType start = {{ 0, 0, 0 }};
ImageType::RegionType region;
region.SetSize( size );
region.SetIndex( start );
image->SetRegions( region );
image->Allocate();
image->FillBuffer( 0 );
ImageType::SpacingType spacing;
spacing[0] = 0.33;
spacing[1] = 0.33;
spacing[2] = 1.20;
image->SetSpacing( spacing );
const ImageType::SpacingType& sp = image->GetSpacing();
std::cout << "Spacing = ";
std::cout << sp[0] << ", " << sp[1] << ", " << sp[2] << std::endl;
ImageType::PointType origin;
origin.Fill(0.0);
image->SetOrigin( origin );
const ImageType::PointType& orgn = image->GetOrigin();
std::cout << "Origin = ";
std::cout << orgn[0] << ", " << orgn[1] << ", " << orgn[2] << std::endl;
PointType point;
point[0] = 1.45;
point[1] = 7.21;
point[2] = 9.28;
ImageType::IndexType pixelIndex;
bool isInside = image->TransformPhysicalPointToIndex( point, pixelIndex );
if ( isInside )
{
ImageType::PixelType pixelValue = image->GetPixel( pixelIndex );
pixelValue += 5;
image->SetPixel( pixelIndex, pixelValue );
}
return EXIT_SUCCESS;
}