Skip to content

transform.resize does not necessarily return the same dtype as its input #7524

@pozdniakovda

Description

@pozdniakovda

Description:

I'm running a deep learning pipeline that relies on transform.resize, but when uint16 images are passed to it, it returns them as float64 (with the same value range, not rescaled). This causes downstream issues due to many packages not supporting float64. Why would transform.resize change the dtype?

Way to reproduce:

import numpy as np
from skimage.transform import resize
img = np.random.uniform(0,65535,10000)
img = img.reshape(100,100)
img = img.astype(np.uint16)
resized = resize(img, (50, 50), preserve_range=True, anti_aliasing=True)
print(f"original dtype: {img.dtype} | resized dtype: {resized.dtype}")

Version information:

3.10.14 (main, May  6 2024, 19:42:50) [GCC 11.2.0]
Linux-6.9.12-200.fc40.x86_64-x86_64-with-glibc2.39
scikit-image version: 0.24.0
numpy version: 1.26.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions