-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Binary image (np.int dtype) become all zero after resizing #5977
Comments
Hi @Guodonggogo, Thanks for reaching out! It looks like the image didn't upload properly in your post. Would you mind re-uploading it? Thanks |
does it work for you with the |
@grlee77 Thanks a lot for replying. I tried result0 = transform.resize(label0,(288,288), mode='constant', order=0, preserve_range=False, anti_aliasing=False) |
OK, with current dev version @grlee77 answer does the trick: import imageio
import numpy as np
import matplotlib.pyplot as plt
from skimage.transform import resize
label = imageio.imread("/tmp/mask.png")
label0 = np.array(label > 0, np.int)
label1 = np.array(label > 0, np.bool_)
result0 = resize(label0, (288, 288), mode='constant', order=0,
preserve_range=False, anti_aliasing=False)
result1 = resize(label1, (288, 288), mode='constant', order=0,
preserve_range=False, anti_aliasing=False)
fig, (ax0, ax1, ax2) = plt.subplots(1, 3, figsize=(8, 4))
ax0.imshow(label)
ax1.imshow(result0)
ax2.imshow(result1)
fig.tight_layout()
plt.show() @Guodonggogo, I edited your report message to correctly display your images 😉 |
@rfezzani Thank you a lot. So, the result above is from 0.19.0.dev0, is it? |
Yes, exactly! I hope you don't mind @Guodonggogo if I convert this issue to discussion. Thank you again for your interest. |
Description
I would like resize a binary image (dtype='np.int') using transform.resize, but its output becomes all zeros. But if I change the input image type to 'np.bool_', the output is correct.
Way to reproduce
Place the full code we need to recreate your issue here
upload all necessary images to github too!
Version information
3.7.4 (default, Aug 13 2019, 20:35:49)
[GCC 7.3.0]
Linux-5.4.0-77-generic-x86_64-with-debian-buster-sid
scikit-image version: 0.17.2
numpy version: 1.16.1
The text was updated successfully, but these errors were encountered: