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('??????');
  • 相关阅读:
    vue中插槽的理解
    父子组件的通信
    vue3.0怎么禁用eslint校验代码和修改端口号
    三大排序
    让机器人实现自主行走 没你想的那么难
    国内外知名激光雷达公司盘点
    激光雷达寿命短,思岚通过什么技术来解决?
    浅谈SLAM的回环检测技术
    除了ROS, 机器人定位导航还有其他方案吗?
    思岚科技即将登陆“2018日本机器人周”精彩抢先看
  • 原文地址:https://www.cnblogs.com/wenning/p/2487220.html
Copyright © 2011-2022 走看看