Image Histogram Matching Using CDF

3 次查看(过去 30 天)
YongHyun
YongHyun 2016-5-17
评论: Tejas 2016-5-19
I wrote a code for image histogram matching using CDF (cumulative distribution function). However, the CDF of result image is differ from the reference image. Please, check the codes and inform me the problems. Note that image is not a 8 bit and has decimal places. Thanks.
reference % reference image
input % input image
re_k = unique(reference(:));
in_k = unique(input(:));
[x,y] = size(input);
[re_counts, re_bins] = hist(reference(:),re_k);
re_cdf = cumsum(re_counts) / sum(re_counts);
[in_counts, in_bins] = hist(input(:),in_k);
in_cdf = cumsum(in_counts) / sum(in_counts);
LU = interp1(re_cdf,re_bins,in_cdf);
test = interp1(re_bins, LU, in(:));
result = reshape(test,x,y);
  1 个评论
Tejas
Tejas 2016-5-19
Hello YongHyun ,
There is a MATLAB function called ' imhistmatch ' which adjusts the histogram of an image to match N-bin histogram of a reference image. You can try to use this.
-Tejas

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by