数字图像处理-第三周 实践课

本文探讨了矩阵运算在创建10x10和100x100矩阵中的应用,以及如何通过直方图显示图像噪声叠加效果。同时,展示了幂次变换对图像直方图均衡化的影响,并生成了浮雕效果和模拟运动模糊的图像,深入理解图像处理中的关键步骤。
摘要由CSDN通过智能技术生成

在这里插入图片描述

创建一个10x10的矩阵, A ( i , j ) = i + j A(i,j)=i+j A(i,j)=i+j
创建一个10x10的矩阵, A ( i , j ) = ( i − 1 ) 2 + ( j − 1 ) 2 A(i,j)=\sqrt{(i-1)^{2}+(j-1)^{2}} A(i,j)=(i1)2+(j1)2

clear;

A=1:10;
B=ones(10,1);
J=B*A;
I=J';
AAA=I+J;
BBB=sqrt((I-1).^2+(J-1).^2);

在这里插入图片描述
创建一个100x100的图像。以A(20,50)为圆心,由内向外颜色由黑渐变为白色。

clear;
A=1:100;
B=ones(100,1);
J=B*A;
I=J';
BBB=sqrt((I-20).^2+(J-50).^2);
g=BBB./max(BBB);
imshow(g);

在这里插入图片描述
图像相加降噪 1、给定一个原始图像 2、通过添加随机噪声产生50张图像 3、比较 10,30,50 张图像叠加(求平均)后的效果 4、并用直方图显示直方图随叠加张数的改变

clear; 
img=imread('d:\dsp\flower.jpg'); 
img=rgb2gray(img); 
for i=1:50 
    B(:,:, i) = uint8(double(img)+normrnd(0,50,size(img))); 
end
C3_10 = uint8(mean( B(:,:,1:10), 3)); 
C3_30 = uint8(mean( B(:,:,1:30), 3)); 
C3_50 = uint8(mean( B(:,:,1:50), 3)); 
subplot(2,5, 1 ); 
imshow(img); 
subplot(2,5, 5+1); 
histogram(img); 
subplot(2,5, 2 ); 
imshow(B(:,:,5)); 
subplot(2,5, 5+2); 
histogram(B(:,:,5)); 
subplot(2,5, 3 ); 
imshow( C3_10 ); 
subplot(2,5, 5+3); 
histogram(C3_10); 
subplot(2,5, 4 ); 
imshow( C3_30 ); 
subplot(2,5, 5+4); 
histogram(C3_30); 
subplot(2,5, 5 ); 
imshow( C3_50 ); 
subplot(2,5, 5+5); 
histogram(C3_50);

在这里插入图片描述
幂次变换1、给定一张图像 S0 2、对图像进行大于1的幂次变换 S1 3、对图像进行小于1的幂次变换 S2 4、分别对S0,S1,S2进行直方图均衡化,S0E,S1E,S2E 5、显示三张图 1) S0,S0直方图,S0E, S0E直方图 2) S1,S1直方图,S1E, S1E直方图 3) S2,S2直方图,S2E, S2E直方图 比较三张图的直方图均衡化后的效果差异。

clear;
S0=rgb2gray(imread('d:\dsp\flower.jpg'));
S1=im2uint8(power((double(S0)./255),0.3));
S2=im2uint8(power((double(S0)./255),3));
S0E=histeq(S0);
S1E=histeq(S1);
S2E=histeq(S2);
figure(1);
subplot(221);imshow(S0);subplot(223);histogram(S0); 
subplot(222);imshow(S0E);subplot(224);histogram(S0E); 
figure(2);
subplot(221);imshow(S1);subplot(223);histogram(S1); 
subplot(222);imshow(S1E);subplot(224);histogram(S1E); 
figure(3);
subplot(221);imshow(S2);subplot(223);histogram(S2); 
subplot(222);imshow(S2E);subplot(224);histogram(S2E); 

在这里插入图片描述
生成浮雕效果的图像,模拟运动模糊图像

clear
img = imread('d:\dsp\flower.jpg'); 
img = rgb2gray(img); 
H = [1 0 0; 0 0 0; 0 0 -1]*5; 
G = uint8(filter2(H, img)+128); %最后统一加上128用于控制灰度,显示出类似浮雕的灰色
figure;
subplot(1,2,1); imshow(img); 
subplot(1,2,2); imshow(G); 
clear 
img = imread('d:\dsp\flower.jpg'); 
img = rgb2gray(img); 
H = eye(30,30)./30.0; 
G = uint8(filter2(H, img)); 
figure; 
subplot(1,2,1); imshow(img); 
subplot(1,2,2); imshow(G);

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值