% I can read in an image and calculate a threshold for which the pixels are above some value, i.e., 6000.
Threshold=Q>6000;
% I can count the number of those pixels above that value
PixelCount = sum(Threshold(:))
% ratio the PixelCount over the total # of pixels in an image with dimensions X1, Y1 to determine a fraction, or percent of pixels above that value
Fraction=PixelCount/(X1*Y1)
But if I wish to calculate the intensity value that represents a desired fraction, i.e. 0.001, - instead of choosing an arbitrary number, like 6000........... how do I program to extract the intensity value that represents cutoff for which 99.9% of pixels have a lower intensity ?
I should mention these are uint16 images.