1

I want to resize(downscale) the ground truth 3d images of brain tumor segmentation.

Here are some g.t. + brain images:

enter image description here

G.t. images are 3d numpy array and consist of only 0 and 1 value(only green voxel and black voxel, brain is not included in g.t. image).

def resize(img, shape, mode='nearest', orig_shape=None, order=3):
    """
    Wrapper for scipy.ndimage.zoom suited for MRI images.
    """

    if orig_shape == None: orig_shape = img.shape

    assert len(shape) == 3, "Can not have more than 3 dimensions"
    factors = (
        shape[0]/orig_shape[0],
        shape[1]/orig_shape[1], 
        shape[2]/orig_shape[2]
    )

    # Resize to the given shape
    return zoom(img, factors, mode=mode, order=order)

# original shape = (150, 512, 512)
# desired shape = (64, 192, 160)

I used scipy zoom, with order 3 and nearest mode. After resizing the images, some of them were ok but some weren't. You can see the problem in the 1st and 2nd images of the above. There are many holes in tumor area which were not there before resizing. The 3rd image doesn't seem to have the issue.

I tinkered some options in zoom function, but didn't find a proper solution. Please help me to solve this. Thank you.

Crispy13
  • 230
  • 1
  • 3
  • 16
  • instead of two unrelated images, we'd like to see the first one BEFORE and AFTER resizing. don't need the whole image, just crop the green part if too large. – lenik May 22 '20 at 11:17
  • what do you mean by _resizing_? It looks like from your images that the green mask has been resampled but not resized. – DrBwts May 22 '20 at 13:02
  • @DrBwts They were resized using zoom function of scipy package(https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.zoom.html). I think that i looks like that because matplotlib's figure size was fixed regradless of resizing.. – Crispy13 May 22 '20 at 13:23
  • add your code so we can see what parameters you used – DrBwts May 22 '20 at 14:57
  • @DrBwts I inserted the code. sorry. – Crispy13 May 23 '20 at 09:42

0 Answers0