Defining a parameter which depends on image luminance distribution function?

1 view (last 30 days)
I am attempting to perform color image enhancement based on a research article found online. I need to perform a brightness adjustment and need to adjust intensity values of each pixel using a non-linear transfer function which is image dependent on the parameter alpha. The parameter alpha depends on the image luminance cumulative distribution function. Alpha is defined as...
alpha = 0 for L < 50, (L - 50)/110 for 50 <= L <= 160, 1 for L > 160.
L is defined as the intensity level corresponding to image luminance Cumulative Distribution Function equal to 0.1.
According to the research article, if 10% or more of all pixels have intensity lower than 50, alpha = 0, when 90% of all pixels have intensity greater than 160, alpha = 1, and if between 10 - 90% of all grayscale pixels have intensity, alpha = (L-50)/110.
Here is my code where i have attempted this...(B represents the grayscale image)
counts = histcounts(B);
cdf = cumsum(counts)/sum(counts);
if cdf <= 50
alpha = 0;
elseif cdf >= 50 && cdf <= 160
alpha = (cdf - 50)/110;
elseif cdf > 160
alpha = 1;
end
I do not believe this code is doing what I need it to do. Any help would be appreciated. I hope I have provided enough information in my question so that my intentions are clear.
Thank you.

Answers (1)

Jeff Miller
Jeff Miller on 14 Feb 2020
If I understand you correctly, I think you want this:
L = quantile(B,0.1);
if L <= 50
alpha = 0;
elseif L >= 50 && L <= 160
alpha = (L - 50)/110;
elseif L > 160
alpha = 1;
end

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!