How to extract frame from Multiframe Image/FrameSet? (JAVA)

I have a multiframe instance loaded with ImageSeriesReader, and i want to know how am i supposed to extract a frame from the result Image/frameSet.

The below script was working fine for singleframe instances loaded as an Image/frameSet:

public static Image axisSlice (Image volume, long[] sliceSize, int[] sliceIndex) {
        VectorUInt32 vectorSize = new VectorUInt32(sliceSize);
        VectorInt32 vectorIndex = new VectorInt32(sliceIndex);
        return SimpleITK.extract(volume, vectorSize, vectorIndex);
    }

i’m working with simpleitk java version.

Hello @Salu_Ramos,

Not sure what is the problem you are encountering. I’m guessing that you are working with a 4D image and want to extract one of the 3D volumes? The extract method is the filter to use. For the specifics see the filter’s documentation which shows how to extract the 3D volume from the 4D one.

If this isn’t the case, please provide additional details, the input image sizes and what you want to extract.

1 Like

Hi @zivy,

you are right, i’m working with 4D Image, the size is [512, 512, 85, 1]. I want a 512x512 extraction, so i need a function that receives de Image and the Index (index is z-axis). Something like this below?

public static Image axisSlice (Image pixeldata, int index) {
        ExtractImageFilter filter = new ExtractImageFilter();
        filter.setIndex(###int vector here###);
        return filter.execute(pixeldata);
    }

What goes inside setIndex? Thankss

Hello @Salu_Ramos,

Pseudo-code, something like:

extract_size = [512,512,0,0] # first two entries are the pixeldata image size and rest are zero
index = [0,0,index,0] 
filter.SetSize(extract_size)
filter.SetIndex(index)
3 Likes

thank you very much! works perfectly

1 Like