图像增强与平滑.docx

上传人:b****2 文档编号:18255486 上传时间:2023-04-24 格式:DOCX 页数:15 大小:1.57MB
下载 相关 举报
图像增强与平滑.docx_第1页
第1页 / 共15页
图像增强与平滑.docx_第2页
第2页 / 共15页
图像增强与平滑.docx_第3页
第3页 / 共15页
图像增强与平滑.docx_第4页
第4页 / 共15页
图像增强与平滑.docx_第5页
第5页 / 共15页
点击查看更多>>
下载资源
资源描述

图像增强与平滑.docx

《图像增强与平滑.docx》由会员分享,可在线阅读,更多相关《图像增强与平滑.docx(15页珍藏版)》请在冰豆网上搜索。

图像增强与平滑.docx

图像增强与平滑

 

数字图像处理

实验报告

 

专业班级:

学生姓名:

学号:

指导老师:

实验一图像增强与平滑

一.实验目的及要求

1.了解MATLAB的操作环境和基本功能。

2.掌握MATLAB中图像增强与平滑的函数的使用方法。

3.加深理解图像增强与平滑的算法原理。

二、实验内容

(一)研究以下程序,分析程序功能;输入执行各命令行,认真观察命令执行的结果。

熟悉程序中所使用函数的调用方法,改变有关参数,观察试验结果。

1.直方图均衡化

clearall;closeall%CleartheMATLABworkspaceofanyvariables

%andcloseopenfigurewindows.

I=imread('pout.tif');%Readsthesampleimages‘pout.tif’,andstoresitin

%anarraynamedI

imshow(I).%displaytheimage

figure,imhist(I)%Createahistogramoftheimageanddisplayitin

%anewfigurewindow.

[I2,T]=histeq(I);%Histogramequalization.

%[J,T]=histeq(I,...)returnsthegrayscaletransformationthatmapsgraylevelsinthe%intensityimageItograylevelsinJ.

figure,imshow(I2)%Displaythenewequalizedimage,I2,inanewfigurewindow.

figure,imhist(I2)%CreateahistogramoftheequalizedimageI2.

figure,plot((0:

255)/255,T);%plotthetransformationcurve.

imwrite(I2,'pout2.png');%WritethenewlyadjustedimageI2toadiskfilenamed

%‘pout2.png’.

imfinfo('pout2.png')%Checkthecontentsofthenewlywrittenfile

均衡化后的图象对比度变强。

注意:

imadjust()

功能:

调整图像灰度值或颜色映像表,也可实现伽马校正。

语法:

J=imadjust(I,[low_inhigh_in],[low_outhigh_out],gamma)

newmap=imadjust(map,[low_inhigh_in],[low_outhigh_out],gamma)

RGB2=imadjust(RGB1,...)

2.直接灰度变换

clearall;closeall

I=imread('cameraman.tif');

J=imadjust(I,[00.2],[0.51]);

imshow(I)

figure,imshow(J)

[X,map]=imread('forest.tif');

figure,imshow(X,map)

I2=ind2gray(X,map);

J2=imadjust(I2,[],[],0.5);

figure,imshow(I2)

figure,imshow(J2)

J3=imadjust(I2,[],[],1.5);

figure,imshow(J3)

helpimadjust%Displaytheimadjust()functioninformation.

3.空域平滑滤波(模糊、去噪)

clearall;closeall

I=imread('eight.tif');

h1=ones(3,3)/9;

h2=ones(5,5)/25;

I1=imfilter(I,h1);

I2=imfilter(I,h2);

figure

(1),imshow(I),title('OriginalImage');

figure

(2),imshow(I1),title('FilteredImageWith3*3')

figure(3),imshow(I2),title('FilteredImageWith5*5')

%加入Gaussian噪声

J1=imnoise(I,'gaussian',0,0.005);

%加入椒盐噪声

J2=imnoise(I,'salt&pepper',0.02);

%对J1、J2进行平均值平滑滤波

K1=imfilter(J1,fspecial('average',3));

K2=imfilter(J2,fspecial('average',3));

figure(4);

subplot(2,2,1),imshow(J1),title('gaussian');

subplot(2,2,2),imshow(J2),title('salt&pepper');

subplot(2,2,3),imshow(K1),title('average');

subplot(2,2,4),imshow(K2);

%对J1、J2进行中值滤波

K3=medfilt2(J1,[33]);

K4=medfilt2(J2,[33]);

figure(5);

subplot(2,2,1),imshow(J1),title('gaussian');

subplot(2,2,2),imshow(J2),title('salt&pepper');

subplot(2,2,3),imshow(K3),title('Medianfiltering');

subplot(2,2,4),imshow(K4)

4.空域锐化滤波

clearall;closeall

I=imread('moon.tif');

w=fspecial('laplacian',0.2)

w8=[1,1,1;1,-8,1;1,1,1]

I1=imfilter(I,w,'replicate');

figure

(1);imshow(I),title('OriginalImage');

figure

(2),imshow(I1),title('LaplacianImage');

f=im2double(I);

f1=imfilter(f,w,'replicate');

figure(3),imshow(f1,[]),title('LaplacianImage');

f2=imfilter(f,w8,'replicate');

f4=f-f1;

f8=f-f2;

figure(4),imshow(f4);

figure(5),imshow(f8);

w=0.16670.66670.1667

0.6667-3.33330.6667

0.16670.66670.1667

w8=111

1-81

111

5.图像的伪彩色处理—密度分割

clearall,closeall

I=imread('earth.gif')

X=grayslice(I,16);

imshow(I),title('OriginalImage')

figure,imshow(X,jet(16)),title('IndexColorImage')

(二)采用MATLAB底层函数编程实现以下灰度线性变换

假定原图像f(x,y)的灰度范围为[a,b],希望变换后图像g(x,y)的灰度范围扩展至[c,d],则线性变换可表示为:

用MATLAB底层函数编程实现上述变换函数。

观察图像‘pout.tif’的灰度直方图,选择合适的参数[a,b]、[c,d]对图像‘pout.tif’进行灰度变换,以获得满意的视觉效果。

clearall;closeall;clc;

I=imread('pout.tif');

I=double(I)/255;

figure

(1),imhist(I)

II=1/0.3*(I-0.3);

figure

(2);subplot(221);imshow(I);

title('原图像');subplot(222);imshow(II);

title('经线性变换后的图像');subplot(223);

imhist(I);title('原图像灰度直方图');

subplot(224);imhist(II);title('经线性变换后的图像灰度直方图');

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1