Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any specific purpose of using different resize methods in the resize function in functional? #9

Open
flora-sun-zhixin opened this issue Feb 25, 2022 · 2 comments

Comments

@flora-sun-zhixin
Copy link

Hi, thanks for sharing the code. After reading and testing the part of what I need, may I ask why you use different resize function here for image(assume is 3 dimensions) and mask(assume is 4 dimensions)?
For dim=3: you used skimage.transform.resize()
For dim=4: you used scipy.ndimage.zoom() for each channel
I tried the two on the same mask and in the resized masks there are some pixels labeled differently. So I am confused whether this will also trigger some mismatch between image and mask?

def resize(img, new_shape, interpolation=1):
    """
    img: [H, W, D, C] or [H, W, D]
    new_shape: [H, W, D]
    """
    type = 1

    if type == 0:
        new_img = skt.resize(img, new_shape, order=interpolation, mode='constant', cval=0, clip=True, anti_aliasing=False)
    else:
        shp = tuple(np.array(new_shape) / np.array(img.shape[:3]))
        # Multichannel
        data = []
        for i in range(img.shape[-1]):
            d0 = zoom(img[..., i].astype(np.uint8).copy(), shp, order=interpolation)
            data.append(d0.copy())
        new_img = np.stack(data, axis=3)

    return new_img
@ZFTurbo
Copy link
Owner

ZFTurbo commented Apr 27, 2022

As I remember I added zoom because it was many times faster than skt.resize. I probably need to create some test script to show it.

@ZFTurbo
Copy link
Owner

ZFTurbo commented Apr 27, 2022

Also I must note I almost not tested masks functionality with this package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants