Advertisement

MATLAB中直方图均衡化和线性与非线性增强

阅读量:

运用知识点:
1、图像增强主要采用线性变换、指数运算以及直方图均衡化等方法来进行处理
2、通过将"黑色变得更暗"和"白色变得更亮"的操作可以有效提高图像对比度水平
3、下面的部分题二就采用了以下所示的这种折线形式

在这里插入图片描述

3、灰度图像的直方图均衡化的步骤如下

在这里插入图片描述

一、

复制代码
    P=im2double(rgb2gray(imread('tes6.jpg')));
    subplot(321),imshow(P),title('原图');
    subplot(322),imhist(P);
    I=imadjust(P,[70/256;180/256],[0/256;70/256]);
    subplot(323),imshow(I),title('线性变化');
    subplot(324),imhist(I);
    J=histeq(I);
    subplot(325),imshow(J),title('直方图均衡化');
    subplot(326),imhist(J);
    
    
      
      
      
      
      
      
      
      
      
    
    AI写代码
在这里插入图片描述

二、经过RGB图像到HSV图像的转换,并对V分量实施直方图均衡化处理
1、运用到了其中的Matlab函数

复制代码
    cat(3,A,B,C);						//将ABC三个矩阵合并
    histeq(M);							//对M进行直方图均衡化
    rgb2hsv(image);
    hsv2rgb(image);
    
    
      
      
      
      
    
    AI写代码
复制代码
     P=imread('picture1.png');
     R=P(:,:,1);
     G=P(:,:,2);
     B=P(:,:,3);
     [H,S,V]=rgb2hsv(P);
     new_v=histeq(V);
     new_hsv2rgb=hsv2rgb(cat(3,H,S,new_v));
     subplot(141),imshow(P),title('rgb原图');
     subplot(142),imshow(V),title('原图V分量');
     subplot(143),imshow(new_v),title('直方图均衡化后V分量');
     subplot(144),imshow(new_hsv2rgb),title('直方图均衡化后rgb');
    
    
      
      
      
      
      
      
      
      
      
      
      
    
    AI写代码
在这里插入图片描述

三、将一幅图像的RGB分量分别进行指数、线性、直方图均衡化变换再合并

复制代码
    P=imread('picture1.png');
    R=P(:,:,1);
    G=P(:,:,2);
    B=P(:,:,3);
    type=3;										//选择变换方式
    type2_m=53;									//指数变换的系数
    type3_a=80/256;type3_b=180/256;type3_c=30/256;type3_d=220/256;		//线性变换的系数,参照上图
    switch type
    case 1									//直方图变换
        new_r=histeq(R);
        new_g=histeq(G);
        new_b=histeq(B);
    case 2									//指数变换
        new_r=type2_m*log(double(R)+1);
        new_g=type2_m*log(double(G)+1);
        new_b=type2_m*log(double(B)+1);
    case 3								//线性变换
        new_r=imadjust(R,[0;type3_a],[0;type3_c]);
        new_g=imadjust(G,[type3_a;type3_b],[type3_c;type3_d]);
        new_b=imadjust(B,[type3_b;1],[type3_d;1]);
    end
    subplot(231),imshow(R),title('r分量');
    subplot(232),imshow(G),title('g分量');
    subplot(233),imshow(B),title('b分量');
    subplot(234),imshow(uint8(new_r)),title('新r分量');
    subplot(235),imshow(uint8(new_g)),title('新g分量');
    subplot(236),imshow(uint8(new_b)),title('新b分量');
    figure;
    subplot(121),imshow(P),title('原图');
    subplot(122),imshow(uint8(cat(3,new_r,new_g,new_b))),title('变换后图像');
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    AI写代码
在这里插入图片描述
在这里插入图片描述

参考文献:
[1] 蔡利梅 王利娟 数字图像处理[M]. 中国矿业大学出版社 2014

全部评论 (0)

还没有任何评论哟~