实验二 图像直方图分析 - 范文中心

实验二 图像直方图分析

09/12

实验二 图像直方图分析

一.实验目的及要求

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

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

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

二、实验内容

(一)研究以下程序,分析程序功能;输入执行各命令行,认真观察命令执行的结果。熟悉程序中所使用函数的调用方法,改变有关参数,观察试验结果。(可将每段程序保存为一个.m 文件)

1.直方图均衡化

clear all; close all % Clear the MATLAB workspace of any variables

% and close open figure windows.

I = imread('pout.tif'); % Reads the sample images ‘ pout.tif’, and stores it in

imshow(I) % an array named I.display the image

figure, imhist(I) % Create a histogram of the image and display it in

% a new figure window.

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

figure, imshow(I2) % Display the new equalized image, I2, in a new figure window.

figure, imhist(I2) % Create a histogram of the equalized image I2. figure,plot((0:255)/255,T); % plot the transformation curve.

imwrite (I2, 'pout2.png'); % Write the newly adjusted image I2 to a disk file named

% ‘pout2.png’.

imfinfo('pout2.png') % Check the contents of the newly written file

2.直接灰度变换

clear all; close all

I = imread('cameraman.tif');

J = imadjust(I,[0 0.2],[0.5 1]);

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)

help imadjust % Display the imadjust() function information.

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

clear all; close all

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('Original Image');

figure(2), imshow(I1), title('Filtered Image With 3*3 ')

figure(3), imshow(I2), title('Filtered Image With 5*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,[3 3]);

K4 = medfilt2(J2,[3 3]);

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(' Median filtering ');

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

4.空域锐化滤波

clear all; close all

I = imread('moon.tif');

w=fspecial('laplacian',0)

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

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

figure(1); imshow(I), title('Original Image');

figure(2), imshow(I1), title('Laplacian Image');

f = im2double(I);

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

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

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

f4 = f-f1;

f8 = f-f2;

figure(4), imshow(f4);

figure(5), imshow(f8);

(二)采用MATLAB 底层函数编程实现

1.灰度变换之动态范围扩展

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

g (x , y ) =d -c [f (x , y ) -a ]+c b -a

用MA TLAB 底层函数编程实现上述变换函数。观察图像‘ pout.tif’的灰度直方图,选择合适的参数[a , b ]、[c , d ]对图像‘pout.tif ’进行灰度变换,以获得满意的视觉效果。

2.非锐化掩蔽和高斯滤波

从原图像中减去其非锐化(平滑过的)图像的过程称为非锐化掩蔽,其基本步骤为: ⑴对原图像进行平滑滤波得到模糊图像f (x , y ) ;

⑵从原图像中减去模糊图像,产生的差值图像称为模板g mask (x , y ) ;

⑶将模板加到原图像上,得到锐化后的图像g (x , y ) 。 即,

g mask (x , y ) =f (x , y ) - f (x , y )

g (x , y ) =f (x , y ) +k *g mask (x , y ) ;k ≥1

用MA TLAB 函数编程实现上述功能。

三、实验设备

1.计算机;

2.MATLAB6.5及以上;

四、预习与思考

1.预习实验内容,阅读教材熟悉实验原理;

2.查阅资料,熟悉MATLAB 的操作环境和基本功能。熟悉实验中涉及的有关函数。

3.利用课余时间,用MATLAB 底层函数编程实现实验内容(二)中的灰度线性变换。

4.你能否给出实现样例程序功能的其它方法?

五、实验报告要求

1. 简述试验的目的和试验原理;

2. 叙述各段程序功能,改变有关函数的参数,分析比较实验结果;

3. 打印出所编写的实验程序。

4. 写出本实验的心得体会及意见。

1.直方图均衡化

I = imread('pout.tif' );

imshow(I)

figure, imhist(I)

[I2,T] = histeq(I);

figure, imshow(I2)

figure, imhist(I2)

figure,plot((0:255)/255,T);

imwrite (I2, 'pout2.png' );

imfinfo('pout2.png' )

2.直接灰度变换

clear all; close all

I = imread('cameraman.tif');

J = imadjust(I,[0 0.2],[0.5 1]);

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)

help imadjust

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

clear all; close all

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('Original Image');

figure(2), imshow(I1), title('Filtered Image With 3*3 ')

figure(3), imshow(I2), title('Filtered Image With 5*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,[3 3]);

K4 = medfilt2(J2,[3 3]);

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(' Median filtering ');

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

4.空域锐化滤波

clear all; close all

I = imread('moon.tif');

w=fspecial('laplacian',0)

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

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

figure(1); imshow(I), title('Original Image');

figure(2), imshow(I1), title('Laplacian Image');

f = im2double(I);

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

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

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

f4 = f-f1;

f8 = f-f2;

figure(4), imshow(f4);

figure(5), imshow(f8);

实验心得

通过本次试验了解和掌握了MATLAB 的操作环境和最基本的功能。学习

到了如何在MATLAB 中处理图像。初步掌握了图像的增强和函数的使用方法。通过实验加深了对算法的理解和掌握, 许多程序算子都是系统自带的,我们最好深入学习一下吧。


相关内容

  • 生物医学图像处理实验指导书 20**年
    实验一 直方图Matlab 运算及C 之间转换 一.实验目的 1. 熟悉利用Matlab 进行图像处理的基本操作,了解图像数据的存储形式及进行图像处理编程的步骤方法. 2. 巩固图像处理编程的步骤格式,理解图像直方图的原理,掌握图像直方图的 ...
  • 基于全局对比度的显著性区域检测
    附件C :译文 基于全局对比度的显著性区域检测 Ming-Ming Cheng1 Guo-Xin Zhang1 Niloy J. Mitra2 Xiaolei Huang3 Shi-Min Hu 1 1 TNList, Tsinghua U ...
  • 动作识别中局部时空特征的运动表示方法研究
    ComputerEngineering andApplications计算机工程与应用 2010.46(34) 7 动作识别巾局部时空特征的运动表示方法研究 雷 LEI 庆1,2,3李绍滋h2Qin91.2.3 LI Shao-zil・2 ...
  • Huffman编码
    <信息论与信源编码>实验报告 1.实验目的 (1) 理解信源编码的基本原理: (2) 熟练掌握Huffman编码的方法: (3) 理解无失真信源编码和限失真编码方法在实际图像信源编码应用中的差异. 2.实验设备与软件 (1) P ...
  • 汽车图像自动识别技术的研究与设计
    应用科举 Ⅵ渊跚 一_% 汽车图像自动识别技术的研究与设计 石磊 (渤海大学信息科学与工程学院辽宁锦州121000) [摘要]结合当今国内外对汽车牌照识别先进技术的研究与所得成果,提出在汽车榆测站实行牌照的图像自动识别技术.这项技术的应用有 ...
  • 室内自主移动机器人定位方法研究综述
    第 卷第 期 年 月 机器人 × ∂ √ 文章编号 2 2 2 室内自主移动机器人定位方法研究综述 李群明 熊蓉 褚健 浙江大学工业控制技术国家重点实验室 浙江杭州 Ξ 摘 要 定位是确定机器人在其作业环境中所处位置的过程 应用传感器感知信 ...
  • 基于数字图像处理的TC4钛合金金相组织定量分析
    2014年4月第9卷 第2期 失效分析与预防 April , 2014Vol. 9, No. 2 基于数字图像处理的TC4钛合金金相组织定量分析 吴 伟1, 吴剑剑1, 张永华2, 邬冠华1, 卢 鹏1, 吴 宇1, 张士晶1 (1. 无损 ...
  • 数字图像处理课程设计之图像特征提取
    河 南 农 业 大 学 <数字图像处理> 题 目: 图像特征提取 学 院:专 业: 班 级: 学 号: 姓 名:指导教师: 成 绩: 时 间: 年 月 日至 一.目的与要求 图像特征提取的目的让计算机具有认识或者识别图像的能力, ...
  • 遥感卫星影像绿地面积解译方法
    北京揽宇方圆信息技术有限公司 遥感卫星影像绿地面积解译方法 遥感技术测定的工作流程与技术路线 根据<湖南省城市园林绿化遥感测定要求(试行)>以及<湖南省园林县城标准>,利用高空间分辨率的遥感影像进行城市绿地调查中具有 ...
  • 中国石油大学(华东)毕业论文有关要求
    中国石油大学(华东) 硕士生学位论文 写作指南 学位与学科建设办公室 2002年9月 目录 编者按 -----------------------1 学位论文应体现的三个规范 --------------1 学位论文和摘要篇幅要求 ---- ...