《数字图像处理》_数字图像处理之
《数字图像处理》由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“数字图像处理之”。
实验五 图像的几何变换
一.实验目的及要求
掌握图像几何变换的基本原理,熟练掌握数字图像的缩放、旋转、平移、镜像和转置的基本原理及其MATLAB编程实现方法。
二、实验内容
(一)研究以下程序,分析程序功能;输入执行各命令行,认真观察命令执行的结果。熟悉程序中所使用函数的调用方法,改变有关参数,观察试验结果。
1.图像缩放 clear all, close all I = imread('cameraman.tif');Scale = 1.35;
% 将图像放大1.35倍
J1 = imresize(I, Scale, 'nearest');
% using the nearest neighbor interpolation J2 = imresize(I, Scale, 'bilinear');
% using the bilinear interpolation imshow(I), title('Original Image');figure, imshow(J1), title('Resized Image--using the nearest neighbor interpolation ');figure, imshow(J2), title('Resized Image--using the bilinear interpolation ');help imresize
% 查看imresize使用帮助
1.95倍
I = imread('cameraman.tif');Scale = 1.96;
% 将图像放大1.96倍
J1 = imresize(I, Scale, 'nearest');
% using the nearest neighbor interpolation J2 = imresize(I, Scale, 'bilinear');
% using the bilinear interpolation imshow(I), title('Original Image');figure, imshow(J1), title('Resized Image--using the nearest neighbor interpolation ');figure, imshow(J2), title('Resized Image--using the bilinear interpolation ');
说明:
注意观察不同插值方法的图像表现; 改变图像缩放因子Scale,重做上述实验。2.图像旋转
clear all, close all I = imread('cameraman.tif');Theta = 45;
% 将图像逆时针旋转45。
J1 = imrotate(I, Theta, 'nearest');
% using the nearest neighbor interpolation Theta =-45;
% 将图像顺时针旋转45。
J2 = imrotate(I, Theta, 'bilinear', 'crop');% using bilinear interpolation and crops the output image imshow(I), title('Original Image');figure, imshow(J1), title('Rotated Image--using the nearest neighbor interpolation ');figure, imshow(J2), title(' Rotated Image--using the bilinear interpolation ');% 查看imrotate使用帮助help imrotate %-------
图像旋转30顺时针逆时针
clear all, close all I = imread('cameraman.tif');Theta = 30;
% 将图像逆时针旋转30。
J1 = imrotate(I, Theta, 'nearest');
% using the nearest neighbor interpolation Theta =-30;
% 将图像顺时针旋转30。
J2 = imrotate(I, Theta, 'bilinear', 'crop');% using bilinear interpolation and crops the output image imshow(I), title('Original Image');figure, imshow(J1), title('Rotated Image--using the nearest neighbor interpolation ');figure, imshow(J2), title(' Rotated Image--using the bilinear interpolation ');7 说明:
注意观察不同插值方法和输出图像后处理方法的图像表现; 改变旋转角度大小和方向,重做上述实验。
3.图像水平镜象
clear all, close all I = imread('cameraman.tif');I1 = flipdim(I,2);
I2 = flipdim(I,1);figure(1), subplot(1,2,1), imshow(I);subplot(1,2,2), imshow(I1);figure(2), subplot(2,1,1), imshow(I);subplot(2,1,2), imshow(I2);%----
(二)用MATLAB编程实现以下图像几何变换(参考自编讲义相关章节)
1.图像扭曲变换 2.球面变换
三、实验设备
1.PIII以上微机; 2.MATLAB6.5;
四、预习与思考
1.预习实验内容,阅读教材熟悉实验原理;
2.查阅资料,熟悉实验中涉及的有关MATLAB函数;
3.利用课余时间,采用MATLAB底层函数编程实现实验内容
(二)中的图像平移、图像转置等几何变换。
五、实验报告要求
1.简述试验的目的和试验原理;
2.叙述各段程序功能,改变有关函数的参数,分析比较实验结果; 3.打印出所编写的实验程序。4.写出本实验的心得体会及意见。
实验六
数字图像处理应用
一.实验目的及要求
1.利用MATLAB提供的图像处理函数实现图像中物体属性的测量; 2.训练综合运用MATLAB图像处理函数的能力; 3.了解数字图像处理基本应用。
二、实验内容
以大米粒特性测量为例,综合应用课程中图像分割、形态学滤波、图像增强、图像特征提取等图像处理方法,实现大米粒特性自动测量。实验过程简述:
1. 读取和显示图像 2. 估计图像背景 3. 获取背景均匀的图像 4. 图像增强 5. 图像二值化分割 6. 区域标记及为彩色处理
7. 测量图像中的区域特性(面积、质心等)
8.统计大米粒的特性分布规律。
(一)研究以下程序,分析程序功能;输入执行各命令行,认真观察命令执行的结果。熟悉程序中所使用函数的调用方法,改变有关参数,观察试验结果。
% Read and Display an Image clear, close all,close all;I = imread('rice.png');
figure, imshow(I)
% Use Morphological Opening to Estimate the Background
background = imopen(I,strel('disk',15));
figure, imshow(background);
%Display the Background Approximation as a Surface
figure, surf(double(background(1:8:end,1:8:end))),zlim([0 255]);set(gca,'ydir','reverse');% Subtract the Background Image from the Original Image I2 = imsubtract(I,background);figure, imshow(I2)% Adjust the Image Contrast I3 = imadjust(I2, stretchlim(I2), [0 1]);figure, imshow(I3);% Apply Thresholding to the Image level = graythresh(I3);bw = im2bw(I3,level);figure, imshow(bw)% Determine the Number of Objects in the Image [labeled,numObjects] = bwlabel(bw,4);
% Label components.numObjects % Examine the Label Matrix RGB_label = label2rgb(labeled, @spring, 'c', 'shuffle');figure, imshow(RGB_label);% Measure Object Properties in the Image graindata = regionprops(labeled,'basic')allgrains = [graindata.Area];% Compute Statistical Properties of Objects in the Image max(allgrains);biggrain = find(allgrains==695)mean(allgrains);figure, hist(allgrains,20);12
(详见MATLAB IPT的 帮助文档demo中的Correcting Nonuniform Illumination)
(二)查看MATLAB IPT 帮助文档,研究其它应用演示
三、实验设备1.PIII以上微机; 2.MATLAB6.5;
四、预习与思考
1.预习实验内容,阅读教材熟悉实验原理; 2.查阅资料,熟悉实验中涉及的有关函数。
3.利用课余时间,采用MATLAB函数编程实现实验内容
(二)。
五、实验报告要求
1.简述试验的目的和试验原理;
2.叙述各段程序功能,改变有关函数的参数,分析比较实验结果; 3.打印出所编写的实验程序。4.写出本实验的心得体会及意见。