ImageMaskType::Pointer image = ImageMaskType::New();
ImageMaskType::SizeType outsize = {650,650,650 };
ImageMaskType::IndexType index = { { 0, 0, 0 } };
ImageMaskType::RegionType region;
ImageMaskType::SpacingType spacing;
region.SetSize(outsize);
region.SetIndex(index);
spacing[0] = 0.5;
spacing[1] = 0.5;
spacing[2] = 0.5;
image->SetSpacing(spacing);
image->SetRegions(region);
cout << movingImageReader->GetOutput()->GetSpacing();
image->Allocate(true); // initialize buffer to zero
ImageMaskType::RegionType insideRegion;
ImageMaskType::SizeType insideSize = { { 30, 30, 30 } };
ImageMaskType::IndexType insideIndex = { { 10, 10, 10 } };
insideRegion.SetSize(insideSize);
insideRegion.SetIndex(insideIndex);
Iterator it(image, insideRegion);
it.GoToBegin();
while (!it.IsAtEnd())
{
it.Set(itk::NumericTraits<PixelType>::max());
++it;
}
spatialObjectMask->SetImage(image);
spatialObjectMask->Update();
transMetric->SetMovingImageMask(spatialObjectMask);
This is the code I added the mask.
The image is the error message. I have checked the spacing, and I set it the same as the original image.
please help me