【问题标题】:How to implement plateau limit histogram equalization algorithm如何实现高原极限直方图均衡算法
【发布时间】:2019-12-25 09:39:54
【问题描述】:

我一直在尝试实现一个简单而简短的算法。我将结果的直方图与原始结果的直方图进行比较,总是有很大的不同。

我一次又一次地查看我的代码。但我看不出有什么问题。我发布了步骤和我的尝试。我的错在哪里?

histogram_of_image = imhist(input_image);
modified_histogram = zeros(1,256);
modified_histogram(1:256)  = (log(histogram_of_image(1:256)+(a))).^(beta);

these_elements_are_not_zero = modified_histogram~= 0;
sum2 = sum(modified_histogram(these_elements_are_not_zero));
cnt2 = size(these_elements_are_not_zero,2);
tcl = sum2/cnt2;
clipped_histogram = zeros(1,256);
for i=1:256
    if((modified_histogram(i)) >= tcl)
    clipped_histogram(i) = tcl;    
    else 
    clipped_histogram(i) = (modified_histogram(i));   
    end
end

PDa = zeros(1,256);
PDa = clipped_histogram / (sum(clipped_histogram)); 
CDa = zeros(1,256);  %create CDa in formula
CDa(1) = PDa(1) ;
for i=2:256
     CDa(i) =  PDa(i) +  CDa(i-1);  
end
value_after_enhancement =  zeros(1,256); 
value_after_enhancement = (255 * CDa); 
b=uint8(0);
output_image=zeros(width,height);
output_image =   value_after_enhancement(input_image+1);
figure;imshow(uint8(output_image));
original_result=imread('testsonuc.bmp');
original_result=double(rgb2gray(original_result));
image_of_dif= zeros(width,height);
figure;imshow(uint8(original_result));

【问题讨论】:

  • these_elements_are_not_zero 将是修改后的直方图上的所有元素,因为在最坏的情况下,如果原始直方图为 0,那么修改后的直方图值将为 0.4805,也许您的意思是在原始直方图?
  • 当我更改原始直方图的代码时。我看到比这更糟糕的结果。
  • 据我了解,您希望直方图在使用 histeq() 指令时看起来像直方图,分布在所有箱中,而不是大部分在最后一个箱上,对吧?
  • 是的,没错。算法也说明了这一点,不是吗?

标签: matlab image-processing


【解决方案1】:

除了绘制结果的一个小细节之外,一切都是正确的,您应该将输出图像从双精度整数转换为无符号整数。output_image = uint8(output_image);

%value_after_enhancement =  zeros(1,256);
value_after_enhancement = (255 * CDa)+1;
%b = uint8(0);
%output_image = zeros(width,height);
output_image = value_after_enhancement(input_image);
output_image = uint8(output_image);
%dif_image = output_image ./ input_image;
%===================================================================
figure('Name','Algorithm Result','NumberTitle','off');
subplot(211);
imshow(output_image);
subplot(212);
Out_Hist = imhist(output_image);
plot(Out_Hist);

【讨论】:

  • 当然会有区别,但是有一点点区别,因为你做了一个直方图处理,你应用了传递函数来增强你的图像,这意味着你增加了你的图像对比度,增加对比度意味着使用直方图中未使用的 bin(在 1 和 256 附近的边界上),并且您将在中间的直方图 bin 中分布未使用的 bin,所以它当然会改变!
  • 好的,我明白了,可能是因为我们使用的图片不同,我在这里使用的是 Lena.png
  • link 我使用来自this 研究论文的原始输出和输入图像。
  • 我必须彻底阅读那篇论文才能看到其他小细节,不幸的是我没有在 IEEExplore 网站上阅读该论文并向您提供反馈的帐户,因为到目前为止您实现的内容是相同的写到什么。除非有额外的细节或进一步的后处理
  • 如果空间分辨率不同,直方图当然会有所不同,直方图只是图像上离散灰度级计数的表示,它取决于像素数和像素灰度级
猜你喜欢
  • 1970-01-01
  • 2020-03-16
  • 2019-07-21
  • 1970-01-01
  • 2017-08-07
  • 2017-05-17
  • 1970-01-01
  • 1970-01-01
  • 2013-12-03
相关资源
最近更新 更多