数字图像处理笔记(二)

五、数字图像增强

  1. 灰度图像直方图查看函数:imhist( );
    clear all;
    close all;
    clc;
    %% 灰度图像直方图
    I = imread('cameraman.tif');
    figure;
    subplot(121);imshow(I);
    subplot(122);imhist(I);
    %%  RGB彩色图像直方图
    I = imread('peppers.png');
    figure;
    subplot(141);imshow(uint8(I));
    subplot(142);imhist(I(:,:,1));title('R');
    subplot(143);imhist(I(:,:,2));title('G');
    subplot(144);imhist(I(:,:,3));title('B');

     

  2. 直方图增强
  • 直方图的均衡化 histeq()
clear all;
close all;
clc;
%% 灰度图像直方图均衡化
I = imread('cameraman.tif');
J = histeq(I);
figure;
subplot(121);imshow(I);
subplot(122);imshow(J);
figure;
subplot(121);imhist(I);title('I');
subplot(122);imhist(J);title('J');
  • 直方图的规定化histeq(I,hgram)
clear all;
close all;
clc;
%% 灰度图像直方图规定化
I = imread('cameraman.tif');
hgram = ones(1,256);
J = histeq(I,hgram);
figure;
subplot(121);imshow(I);
subplot(122);imshow(J);
figure;
subplot(121);imhist(I);title('I');
subplot(122);imhist(J);title('J');

六、图像的均值标准差

 1. 均值mean2( )

clear all;
close all;
clc;
%% 图像均值的计算
I = imread('peppers.png');
J = rgb2gray(I);
gray = mean2(J);
rgb = mean2(I);
r = mean2(I(:,:,1));
g = mean2(I(:,:,2));
b = mean2(I(:,:,3));

 

2.  标准差 std( )

clear all;
close all;
clc;
I = imread('cameraman.tif');
S1 = std2(I);
J = histeq(I);
S2 = std2(J);

 3. 相关系数corr2( )

clear all;
close all;
clc;
I = imread('cameraman.tif');
J = medfilt2(I);
r = corr2(I,J);
figure;
subplot(121);imshow(I);
subplot(122);imshow(J);

4. 绘制图像的等高线imcontour( )

clear all;
close all;
clc;
I = imread('cameraman.tif');
J = imread('peppers.png');
J = im2double(J);
figure;
subplot(131);imshow(I);
subplot(132);imcontour(I);%自动选取条数n
subplot(132);imcontour(I,3);%指定3条
figure;
subplot(141);imshow(J);
subplot(142);imcontour(J(:,:,1),5);
subplot(143);imcontour(J(:,:,2),5);
subplot(144);imcontour(J(:,:,3),5);

七、 空域滤波

 1. 线性空域滤波

滤波矩阵为     ,对应函数表达式    

clear all;
close all;
clc;
% 椒盐噪声滤波
I = imread('cameraman.tif');
J = imnoise(I,'salt & pepper',0.01);
h = ones(3,3)/5;
h(1,1) = 0;
h(1,3) = 0;
h(3,1) = 0;
h(3,3) = 0;
K = imfilter(J,h);
figure;
subplot(131);imshow(I);
subplot(132);imshow(J);
subplot(133);imshow(K);

% 高斯噪声二维卷积
I1 = imread('rice.png');
J1 = imnoise(I1,'gaussian',0,0.01);
h1 = ones(3,3)/9;
K1 = conv2(J1,h1);
figure;
subplot(131);imshow(I1);
subplot(132);imshow(J1);
subplot(133);imshow(K1);

2. 非线性空域滤波:中值滤波medfilt2()、顺序统计滤波ordfilt2() 可以让图像变得更亮或更暗、自适应滤波wiener2()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值