Optimizing adaptive histogram equalization function

1 view (last 30 days)
Hello,
I am running adaptive histogram equalization on terabytes of video, and found out that the majority of the time is spent on less than 10 lines of code in the function. I ran the profiler on my program and found that clipHistogram function is really eating up all my time. Note that clipHistogram is called during adapthisteq. To narrow it down more lines 274-286 in that function are taking up the time. Is there a faster way to clip the histogram then these 10 lines of code? Can I vectorize this information, and if I can how do I do it?
for k=1:numBins
if imgHist(k) > clipLimit
imgHist(k) = clipLimit;
else
if imgHist(k) > upperLimit % high bin count
totalExcess = totalExcess - (clipLimit - imgHist(k));
imgHist(k) = clipLimit;
else
totalExcess = totalExcess - avgBinIncr;
imgHist(k) = imgHist(k) + avgBinIncr;
end
end
end
Regards, Andrew

Answers (0)

Community Treasure Hunt

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

Start Hunting!