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

[Bug] Patches truncated for 16 bit images #166

Closed
mathieuboudreau opened this issue Feb 22, 2019 · 6 comments · Fixed by #243
Closed

[Bug] Patches truncated for 16 bit images #166

mathieuboudreau opened this issue Feb 22, 2019 · 6 comments · Fixed by #243

Comments

@mathieuboudreau
Copy link
Member

Likely due to this line: https://github.com/neuropoly/axondeepseg/blob/57047da51781c12d06c1b5d59dcb705bf4adc376/AxonDeepSeg/data_management/dataset_building.py#L44

Combining preserve_range plus asint may be what's truncating the patches (all white).

capture d ecran 2019-02-22 a 14 17 54

The solution may be as simple as removing the asint call.

@maxwab you wrote that line; do you see any issues with removing the asint call? I'll double check the rest of the code to make sure it's not assumed to be an 8bit int anywhere else. I guess it means that if I remove this, the data size will be much larger... Otherwise, removing the perserve_range could also possibly be a solution.

@mathieuboudreau
Copy link
Member Author

@perone do you think there would be any issues in Tensorflow with having a mixed dataset (8bit + 16bit) during the training?

@maxwab
Copy link
Contributor

maxwab commented Feb 22, 2019

Hi @mathieuboudreau,
At first glance I don't see any problem with removing the .astype(int) call.
The most likely reason I added this call at the time was to ensure the type of img. As far as I can tell, the reason was not memory usage.

@mathieuboudreau
Copy link
Member Author

Thanks!

Poking around, although I was able to find where the images are converted toint patches in the dataset building stage, but in the segmentation call the patches are separated by a different function, im2patchoverlap, which doesn't appear to have an int conversion.

https://github.com/neuropoly/axondeepseg/blob/432af8265acc02401d8edd1e93e6e45b19471dbe/AxonDeepSeg/apply_model.py#L351

This is also slightly concerning that we are using two different parts of the code to create patches.

Maybe the short term solution for our current user who's dataset has a mix of 8bit and 16 bit files will be to just convert the 8bit files. I'll explore this and give them the option early next week.

@mathieuboudreau
Copy link
Member Author

mathieuboudreau commented Feb 22, 2019

Actually, here are all the calls to astype():

https://github.com/neuropoly/axondeepseg/blob/432af8265acc02401d8edd1e93e6e45b19471dbe/AxonDeepSeg/apply_model.py#L402-L403

https://github.com/neuropoly/axondeepseg/blob/432af8265acc02401d8edd1e93e6e45b19471dbe/AxonDeepSeg/apply_model.py#L402-L403

https://github.com/neuropoly/axondeepseg/blob/1edb7dd5bb3ccc2e1488015a3401b17b9b480cfd/AxonDeepSeg/data_management/dataset_building.py#L44

https://github.com/neuropoly/axondeepseg/blob/1edb7dd5bb3ccc2e1488015a3401b17b9b480cfd/AxonDeepSeg/data_management/dataset_building.py#L44

https://github.com/neuropoly/axondeepseg/blob/49795de3617e5a453c2b7bba36f2756f9cfcbc3c/AxonDeepSeg/data_management/input_data.py#L329

https://github.com/neuropoly/axondeepseg/blob/49795de3617e5a453c2b7bba36f2756f9cfcbc3c/AxonDeepSeg/data_management/input_data.py#L388

https://github.com/neuropoly/axondeepseg/blob/49795de3617e5a453c2b7bba36f2756f9cfcbc3c/AxonDeepSeg/testing/segmentation_scoring.py#L36

https://github.com/neuropoly/axondeepseg/blob/49795de3617e5a453c2b7bba36f2756f9cfcbc3c/AxonDeepSeg/testing/segmentation_scoring.py#L51

https://github.com/neuropoly/axondeepseg/blob/49795de3617e5a453c2b7bba36f2756f9cfcbc3c/AxonDeepSeg/testing/segmentation_scoring.py#L124

https://github.com/neuropoly/axondeepseg/blob/b3d9574d06739c7e52d2ce832b5efa90031a5f69/AxonDeepSeg/visualization/get_masks.py#L29-L30

https://github.com/neuropoly/axondeepseg/blob/1edb7dd5bb3ccc2e1488015a3401b17b9b480cfd/AxonDeepSeg/testing/noise_simulation.py#L36

https://github.com/neuropoly/axondeepseg/blob/1edb7dd5bb3ccc2e1488015a3401b17b9b480cfd/AxonDeepSeg/testing/noise_simulation.py#L57

https://github.com/neuropoly/axondeepseg/blob/1edb7dd5bb3ccc2e1488015a3401b17b9b480cfd/AxonDeepSeg/testing/noise_simulation.py#L75

https://github.com/neuropoly/axondeepseg/blob/476bb3fcf1a5092514c4c73d124a8e9f46d6015b/AxonDeepSeg/data_management/data_augmentation.py#L109-L114

https://github.com/neuropoly/axondeepseg/blob/476bb3fcf1a5092514c4c73d124a8e9f46d6015b/AxonDeepSeg/data_management/data_augmentation.py#L138-L145

https://github.com/neuropoly/axondeepseg/blob/476bb3fcf1a5092514c4c73d124a8e9f46d6015b/AxonDeepSeg/data_management/data_augmentation.py#L185-L191

@mathieuboudreau
Copy link
Member Author

It may also be the "L" mode: python-pillow/Pillow#3011

L mode is 8bit pixel (black and white): https://docs.scipy.org/doc/scipy/reference/generated/scipy.misc.imread.html

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