I’m trying to add an uniform (in color and size) margin to a 3D image and the only filter that always comes up in google is itk::ConstantPadImageFilter. https://itk.org/Doxygen/html/classitk_1_1ConstantPadImageFilter.html
Documentation clearly states:
Increase the image size by padding with a constant value.
But I would like the output image to have the same size as the input image, i.e. I would like the padding to go “inward” and overwrite some of the content of my image.
Just for information, here is the code I have that creates nice black margins but increase the size of my image by 10 in all dimensions (5+5).
// add black border to prevent leakage
using ConstantPadImageFilterType = itk::ConstantPadImageFilter <Image3d, Image3d>;
ConstantPadImageFilterType::Pointer padFilter = ConstantPadImageFilterType::New();
v_ExtendRegion.Fill(5); // 5 pixels wide
padFilter->SetConstant(-3000); // very low value (black)
Any idea on how to proceed from there ?