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('??????');
  • 相关阅读:
    c&c++中的宏
    cmake教程
    什么是Grunt
    npm-install camo
    在node.js中建立你的第一个HTTp服务器
    highChart数据动态更新
    css:before和after中的content属性
    清除float浮动三种方式
    中文标准web字体
    网站桌面端和手机端不同url的设置
  • 原文地址:https://www.cnblogs.com/wenning/p/2487220.html
Copyright © 2011-2022 走看看