[ITK] Image bounds question

smrolfe at u.washington.edu smrolfe at u.washington.edu
Wed Sep 10 17:25:57 EDT 2014


Hello,

I've been using a program for adding a constant padding to an image.  This has 
worked to pad each edge, resulting in negative bounds.  Now I've added the code 
as a subroutine and the behavior has changed.  The padding now appears on only 
the positive side of the bounds, so the bounds still start at 0, 0, 0.

It appears that writing the image changes the behavior of the bounds? Does this 
have to do with the position of the origin?  I'd like to understand this 
better.  My subroutine is below.

InternalImageType::Pointer PadImage(InternalImageType::Pointer origIm, double 
padFactor )
{
 	typedef itk::ConstantPadImageFilter <InternalImageType, 
InternalImageType> ConstantPadImageFilterType;

 	InternalImageType::SizeType lowerExtendRegion;
 	lowerExtendRegion[0] = padFactor ;
 	lowerExtendRegion[1] = padFactor ;
 	lowerExtendRegion[2] = padFactor ;

 	InternalImageType::SizeType upperExtendRegion;
 	upperExtendRegion[0] = padFactor ;
 	upperExtendRegion[1] = padFactor ;
 	upperExtendRegion[2] = padFactor ;

 	InternalImageType::PixelType constantPixel = 0;

 	ConstantPadImageFilterType::Pointer padFilter = 
ConstantPadImageFilterType::New();
 	padFilter->SetInput(origIm);
 	padFilter->SetPadLowerBound(lowerExtendRegion);
 	padFilter->SetPadUpperBound(upperExtendRegion);
 	padFilter->SetConstant(0);
 	padFilter->Update();

 	return padFilter->GetOutput();
}



Thanks,
Sara




More information about the Community mailing list