【问题标题】:Apply new equalized histogram on the image matrix in matlab在matlab中的图像矩阵上应用新的均衡直方图
【发布时间】:2013-06-25 17:04:16
【问题描述】:

假设基于我的my previous question 我已经均衡了图像的直方图,现在问题是如何在图像上应用这个新的均衡直方图?
我的意思是从新的均衡直方图中获取新图像的算法是什么?
我见过a code about this in the net.
很明显,这张照片中显示的最后一个 for 循环用于在图像矩阵上应用均衡直方图。

但我不明白使用的算法。
再次注意,这是一项大学作业,我不允许使用图像处理工具箱中提供的内置功能。

【问题讨论】:

    标签: image matlab image-processing histogram


    【解决方案1】:

    我找到了在图像矩阵here上应用新的均衡直方图的算法。
    该网页对我有帮助的具体部分如下图所示:

    我为实现这个算法而写的代码在this link.
    请注意,文件“HistogramEqualization”中的第 22 到 24 行为灰度图像实现了上述算法。 RGB 的代码是相同的,只是它应该为每个颜色通道重复。

    【讨论】:

      【解决方案2】:
      1. 为图像创建直方图。
      2. 计算累积分布函数直方图。
      3. 通过一般直方图均衡公式计算新值。
      4. 为图像中的每个灰度值分配新值。

        clc
        close all
        clear all
        %% HISTOGRAM EQULAIZER
        %%
        I1= imread ('C:\Users\sepideh\Pictures\dip\PC040311.jpg');
        zz=rgb2gray(I1);
        figure,subplot(1,2,1),imshow(zz), title('original image')
        subplot(1,2,2),imhist(zz),title('original image histogram')
        
        %% Calculating the CDF 
        hst=imhist(zz);
        j=1;
        cdff(1,1)=hst(1,1);
        for i=2:256
        cdff(i)=hst(i)+cdff(i-j); 
        end
        cdff1=cdff';
        cdf_min=min(cdff);
        [row col]=size(zz);
        mn=row*col;
        figure, plot(cdff), title('CDF of Image')
        %% calcuting new intensity
        for indx=1:length(cdff)
        h(indx)=round((cdff(indx)-cdf_min)/(mn-cdf_min)*255);
        
        end
        h1=h';
        figure,plot(h1), title('New value for General Histogram')
        
        %% EQULIZED IMAGE
        
        HIm=uint8(zeros(size(zz,1),size(zz,2)));
        
        for i=1:row;
        for j=1:col;
        HIm(i,j) = h((zz(i,j)+1));
        end
        end
        
        figure,subplot(1,2,1),imshow(HIm), title('Equlized Image')
        subplot(1,2,2),imhist(HIm) ,title('Equlized image histogram')
        

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-11-20
        • 1970-01-01
        • 1970-01-01
        • 2019-07-21
        • 1970-01-01
        相关资源
        最近更新 更多