Simple ITK Crop Image

Hey guys:

I have a 3D grey-level image (256, 256, 192);
I have a 3D label-image binary (1 and 0) to define a segmentation (256, 256, 192);

I use LabelShapeStatisticsImageFilter to get a bounding box or region for my label image;
The region/boundingbox output is something like this: [115, 58, 122,32, 18, 8]

I then use that region info to crop this bounding box region from grey-level image;
The crop filter takes an image, lowerBoundaryCropSize and upperBoundaryCropSize.

Question: How to find out those boundary indexes from region info?

I tried many combinations, like three first numbers for lower boundary, and the rest for upper boundary. Also subtracting the last three numbers from initial ones and set is as either lower or upper boundary. No success.

Error:The input image’s size [256, 256, 192] is less than the total of the crop size!

thaks in advance;

The return follows the SimpleITK common convention for converting a region into a array: [idx_x, idx_y, idx_z, size_x, size_y, size_z].

The RegionOfInterest filter has the index and size parameters which conveniently works with the output values produced.

1 Like

Excellent. Used and Worked.
A single observation; RegionOfInterest takes as input (Image, Size, Index) rather than (Image, Region) .