I am using ITK C++, and I have applied Otsu thresholding to derive a threshold for a particular image. Now, I want to know the quantile this threshold is set. What would be the best way to do this? Also, ultimately, I want to use this quantile value to threshold other images, which I believe I should use itk::Histogram. Any suggestions appreciated.
You could create a histogram of your image with the same number of bins as Otsu thresholding used. Then translate the Otsu-threshold to a bin index. Sum up all frequencies for bins up to the threshold bin and divide by the total frequency. That should give you the corresponding quantile.
Thank you so much @crossmanith !
Is there an Example that you could recommend to create a histogram of an image? I could only find https://itk.org/Doxygen/html/Examples_2Statistics_2Histogram_8cxx-example.html , which does not show image → histogram conversion as an example.
P.S. Looks like I have to read Book2 the relevant section. Will go through p.482+ and come back!
Thank you so much! This helped me to find the relevant example associated to the filter!
The examples are better viewed on GitHub, as there is access to history and the rest of the source code. This particular example is here: https://github.com/InsightSoftwareConsortium/ITK/blob/master/Examples/Statistics/ImageHistogram3.cxx.
Thank you very much! A lot of learning, this is definitely helpful!!!
Now that I can compute the percentile and also apply thresholds for each individual z-slices, I am having trouble of assembling that back to a 3D image.
I was basing my program with the following example:
But that only extracts one slice and paste(?)s. Is there a good example for applying a filter to each slice of a 3D image?
Thank you so much!
Just to make sure I understand this correctly - I have to apply different thresholds for each slices (it maintains the percentile, but not the actual value) - I can calculate these values by extracting the slice, but would it be possible to apply this to the slicebysliceImagefilter?
Thank you everyone, just to follow up, I was able to create a custom filter which could be feed in to the slicebysliceImageFilter that @zivy pointed to! (Learned how to make a custom filter!).