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.
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);
}
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)