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

OtsuMultipleThresholdsImageFilter #25

Open
LPUoO opened this issue Jan 16, 2023 · 3 comments
Open

OtsuMultipleThresholdsImageFilter #25

LPUoO opened this issue Jan 16, 2023 · 3 comments

Comments

@LPUoO
Copy link

LPUoO commented Jan 16, 2023

Hi @blowekamp,

I am running into an issue where when running OtsuMultipleThresholdsImageFilter on an 32-bit image containing NaNs it returns an image where all pixel values = number_of_thresholds.

So I am wondering, can OtsuMultipleThresholdsImageFilter segment an image when it contains NaNs?

Thanks a lot!

@lassoan
Copy link
Collaborator

lassoan commented Jan 16, 2023

In general, I would recommend to stay away from Nan values and replace them by valid numbers before you do any processing.

The reason is that Nan can mean many different things, so algorithm developers can only guess what to do with NaN values. Even if the algorithm developer could implement computations based on some common interpretation, the significantly increased computation time, code complexity, overhead in implementation, testing, documentation, user support, and potential issues caused by silently choosing an arbitrary interpretation, far outweigh the benefits from supporting a tiny fraction of use cases.

If you want to use Nan values for masking then I would recommend to use a separate mask image instead.

@LPUoO
Copy link
Author

LPUoO commented Jan 16, 2023

Thank you @lassoan for the clarification.

I am indeed using NaNs for masking.
I wanted to use NaNs so that OtsuMultipleThresholdsImageFilter only creates classes in my foreground without being affected by the pixel distribution of the background.

I would recommend to stay away from Nan values and replace them by valid numbers before you do any processing.

Wouldn't that affect the segmentation/classification?

Thanks a lot

@lassoan
Copy link
Collaborator

lassoan commented Jan 16, 2023

I'm not sure if Otsu implementation in ITK can take a mask image, but you can set all the NaN values to a very large value, compute the image histogram with a bin range that does not include the very large value, then get the Otsu threshold value from that histogram.

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

No branches or pull requests

2 participants