I have got numpy arrays consisting of only 0s and 1s. They are supposed to be the target for an Image Segmentation Model, so I am trying to resize them all so they have the same dimensions. The problem is that when resizing with the code below, the image is not being kept as a binary. Instead, I get a lot of float values between 0 and 1, which seem to be affecting my model's performance.
import skimage.transform as st
new_label_data = st.resize(label_data, (1024, 1024), order=0, anti_aliasing=False)
So that begs the question: how can I resize the binary arrays and make sure the output also has only 0s and 1s?
Use preserve_range=True
as well:
new_label_data = st.resize(label_data, (1024, 1024), order=0, preserve_range=True, anti_aliasing=False)
See st.resize
for more details.