zoukankan      html  css  js  c++  java
  • 直方图均衡

    function Hisequalization()
    %读取图像
    input_image=imread('./a.bmp', 'bmp');
    F=double(input_image);
    [m,n]=size(F);
    figure;
    subplot(221);
    imshow(uint8(F));
    title('????');
    subplot(222);
    imhist(uint8(F));
    His=zeros(1,256);%
    for x=1:m
        for y=1:n
            M(x,y)=F(x,y);
            a=F(x,y);
            His(a+1)=His(a+1)+1;
        end
    end
    for x=1:256
        normHis(x)=His(x)/(m*n);%????????????????
        if(x~=1)
            cumuHis(x)=cumuHis(x-1)+normHis(x);%??????????
        else
            cumuHis(x)=normHis(x);
        end
    end
    for i=1:256
        Map(i)=floor(cumuHis(i)*255+0.5);%????
    end
     
    for x=1:m
        for y=1:n
            tmp=M(x,y)+1;
            M(x,y)=Map(tmp);
        end
    end
    subplot(223);
    imshow(uint8(M));
    title('??????');
    subplot(224);
    imhist(uint8(M));
    %imwrite(uint8(M),'./ttttttt.bmp');
     
     
    对于彩色图:
    function Hisequalization2()
    input_image=imread('./test.png', 'png');
    F=double(input_image);
    [m,n,o]=size(F);
    figure;
    subplot(241);
    imshow(uint8(F));
    title('????');
    for z=1:3
        for x=1:m
            for y=1:n
                m(x,y)=F(x,y,z);
            end
        end
        subplot(2,4,1+z);
        imhist(uint8(m));
    end
    for z=1:3
      
    His=zeros(1,256);
    for x=1:m
        for y=1:n
            M(x,y,z)=F(x,y,z);
            a=F(x,y,z);
            His(a+1)=His(a+1)+1;
        end
    end
    sizeof(His);
    normHis=zeros(1,256);
    for x=1:256
        normHis(x)=His(x)/(m*n);
        if(x~=1)
            cumuHis(x)=cumuHis(x-1)+normHis(x);
        else
            cumuHis(x)=normHis(x);
        end
    end
    for i=1:256
        Map(i)=floor(cumuHis(i)*255+0.5);
    end
     
    for x=1:m
        for y=1:n
            tmp=M(x,y,z)+1;
            M(x,y,z)=Map(tmp);
        end
    end
    for x=1:m
        for y=1:n
           
            m(x,y)=M(x,y,z);
        end
    end
    subplot(2,4,z+5);
    imhest(uint8(m));
    end
    subplot(225);
    imshow(uint8(M));
    title('??????');
  • 相关阅读:
    加解密工具类(含keystore导出pfx)
    Java使用数字证书加密通信(加解密/加签验签)
    关于javax.crypto.BadPaddingException: Blocktype错误的几种解决方法
    产生定长的随机数
    数字证书生成--加密密/加签验签
    随机指定范围内N个不重复的数
    sql2012还原sql2008备份文件语句
    uploadify API
    海量数据处理分析
    .net经验积累
  • 原文地址:https://www.cnblogs.com/wenning/p/2487220.html
Copyright © 2011-2022 走看看