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

image_and_masks contains black png images #2

Open
hxngillani opened this issue Sep 6, 2020 · 5 comments
Open

image_and_masks contains black png images #2

hxngillani opened this issue Sep 6, 2020 · 5 comments
Labels
question Further information is requested

Comments

@hxngillani
Copy link

why there are black .png images in mask folders ?

@ianhi
Copy link
Owner

ianhi commented Sep 6, 2020

Hi @hxngillani those are where the mask data are stored. They show up as black when you look at them because they only hold the class data for each pixel. So the only values in the file are 0,1,2. Since these are all very low values the PNG will appear black when you try view it with an image viewer. We do this because it's easier to store the data this way than to store the colors of each class. So we store them as 0,1,2 and then convert the classes to colors when we want to display them. The code that does this when you load a premade mask is here:

self.colors = np.vstack([[0,0,0],plt.get_cmap(self.colors)(np.arange(len(classes)))[:,:3]])

idx = self.class_mask != 0
c_overlay = self.colors[self.class_mask[idx]]*255*self.overlay_alpha
array[idx] = (c_overlay + self.img[idx]*(1-self.overlay_alpha))

@hxngillani
Copy link
Author

thanks you ianhi :)

@MBelkhechine
Copy link

Hi,

thank you for explaining this question.

Would you please tell me, how you are storing the class indexes? Is it in the B value of the RGB color scheme?

@ianhi
Copy link
Owner

ianhi commented Jan 10, 2021

@MBelkhechine good question. They are actually stored as black and white images so the arrays have shape (450, 450). You can check this by opening one up using skimage.io.imread:

from skimage import io
arr = io.imread('data/image_and_masks/train_masks/train/0_159350906_z_-2.5.png')
print(arr.shape)

@ianhi ianhi added the question Further information is requested label Jan 10, 2021
@MBelkhechine
Copy link

Thank you for your prompt response.

I had a closer look at the masks provided in the dataset and it seems that the class indexes are stored in all the RGB color space dimensions e.g. Pixels labelled as cell2 will have this tuple value rgb(2,2,2).

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

No branches or pull requests

3 participants