数字图像处理 MATLAB 代码 第三章 亮度变化与空间滤波

% f = imread('C:\Users\Arthur\Desktop\MATLABPicture\dipum_images_ch02\Fig0203(a)(chest-xray).tif')
% [M, N] = size(f)
% whos f
% imshow(f, [10 240])
%-----------------------------------------------------------------------------------------------
% f = imread('C:\Users\Arthur\Desktop\MATLABPicture\dipum_images_ch03\Fig0303(a)(breast).tif')
% imshow(f)%亮度变化
% g1 = imadjust(f, [0 1], [1 0])%反色
% imshow(g1)
% g2 = imcomplement(f)%反色
% imshow(g2)
% g3 = imadjust(f, [ ], [ ], 2)%gammma = 2
% imshow(g3)
%-----------------------------------------------------------------------------------------------
% f = imread('C:\Users\Arthur\Desktop\MATLABPicture\dipum_images_ch03\Fig0305(a)(spectrum).tif')
% subplot(1, 2, 1)
% imshow(f)
% g = im2uint8(mat2gray(log(1 + double(f)))) %对数和对比度拉伸变化
% subplot(1, 2, 2)
% imshow(g)
%-----------------------------------------------------------------------------------------------
% f = imread('C:\Users\Arthur\Desktop\MATLABPicture\dipum_images_ch03\Fig0306(a)(bone-scan-GE).tif')
% h = imhist(f)%直方图
% h1 = h(1:10:256)
% horz = 1:10:256
% ylim('auto')%自动坐标轴大小
% xlim('auto')
% subplot(1, 2, 1)
% bar(horz, h1)
% subplot(1, 2, 2)
% stem(horz, h1, 'fill')
%-----------------------------------------------------------------------------------------------
% f = imread('C:\Users\Arthur\Desktop\MATLABPicture\dipum_images_ch03\Fig0308(a)(pollen).tif')
% subplot(1, 2, 1)
% imshow(f)
% h = histeq(f)%直方图均值化
% subplot(1, 2, 2)
% imshow(h)
%-----------------------------------------------------------------------------------------------
% f = imread('C:\Users\Arthur\Desktop\MATLABPicture\dipum_images_ch03\Fig0310(a)(Moon Phobos).tif')
% subplot(1, 2, 1)
% imshow(f)
% h = histeq(f, p)%直方图匹配 p是想要的直方图样子
% subplot(1, 2, 2)
% imshow(h)
% %-----------------------------------------------------------------------------------------------
% f = imread('C:\Users\Arthur\Desktop\MATLABPicture\dipum_images_ch03\Fig0315(a)(original_test_pattern).tif')
% f = im2double(f)%这里必须转化
% subplot(2, 2, 1)
% imshow(f)
% w = ones(31)
% gd = imfilter(f, w)
% subplot(2, 2, 2)
% imshow(gd, [ ])
% gr = imfilter(f, w, 'replicate')
% subplot(2, 2, 3)
% imshow(gr, [ ])
% %-----------------------------------------------------------------------------------------------
% f = imread('C:\Users\Arthur\Desktop\MATLABPicture\dipum_images_ch03\Fig0316(a)(moon).tif')
% subplot(2, 2, 1)
% imshow(f)
% w = fspecial('laplacian', 0)%线性空间滤波器 拉普拉斯
% g1 = imfilter(f, w, 'replicate')
% subplot(2, 2, 2)
% imshow(g1, [ ])
% f2 = im2double(f)%转为double避免被截掉
% g2 = imfilter(f2, w, 'replicate')
% subplot(2, 2, 3)
% imshow(g2, [ ])
% g = f2 - g2
% subplot(2, 2, 4)
% imshow(g)
%-----------------------------------------------------------------------------------------------
f = imread('C:\Users\Arthur\Desktop\MATLABPicture\dipum_images_ch03\Fig0318(a)(ckt-board-orig).tif')
subplot(2, 2, 1)
imshow(f)
fn = imnoise(f, 'salt & pepper', 0.2)%椒盐
subplot(2, 2, 2)
imshow(fn, [ ])
gm = medfilt2(fn)%中值滤波
subplot(2, 2, 3)
imshow(gm, [ ])
gms = medfilt2(fn, 'symmetric') %减少黑色边界
subplot(2, 2, 4)
imshow(gms)













 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值