《数字图像处理》实验报告
实验一 图像增强
班级: 姓名: 学号:
实验目的
一、熟悉MATLAB中的图像处理工具箱。
二、熟悉MATLAB中常用的图像处理函数。
三、掌握图像增强的基本原理与实现方法,掌握基本的空间域操作。
四、了解imread、imshow、imhist、imwrite、rgb2gray、mat2gray、imresize、imrotate、imtransform等函数的使用方法。
五、实验内容
1. 熟悉MATLAB图像处理工具箱的功能及常用的图像处理函数。
2.实现“DIPUM2E_PROJECT_STATEMENTS”中的PROJECT 2.1 、2.2、2.
3、2.5、3.
1、3.5 、3.6
六、实验结果
第一题
function I = isinteger(A) if ~isnumeric(A) error(\'A must be a numeric array.\'); end
A = double(A); I = A == floor(A); A=[6.1 2.1;0.1 2] isinteger(A) 结果ans = 0 0 0 1 2.2代码
function E = iseven(A) if ~isnumeric(A) error(\'A must be a numeric array.\'); end A = double(A); E = floor(A/2) == (A/2); A=[3 5 ;0.1 6] iseven(A) 结果ans =
《数字图像处理》实验报告
0 0 0 1 2.3代码
function D = isodd(A) if ~isnumeric(A) error(\'A must be a numeric array.\'); end
A = double(A); D = floor((A + 1)/2) == ((A + 1)/2); A=[2 3;6 1] isodd(A) 结果 ans = 0 1 0 1 2.5代码
function [I, map] = imagein1(path) if nargin
original_directory = pwd; [file, pathname] = uigetfile(\'*.*\', \'Image Open\'); if isequal(file, 0) | isequal(pathname, 0) disp(\'Image input canceled.\'); I = []; map = []; else
[I, map] = imread(file); end 结果
>>imagein1 Image input canceled.ans = []
3.1、代码
《数字图像处理》实验报告
function z = intxform (s, map) clain = cla(s); [s, revertcla] = tofloat(s); x = linspace(0, 1, numel(map))\'; y = map(:); z = interp1(x, y, s, \'linear\'); z = revertcla(z); A=imread(\'Fig0210(a).tif\'); subplot(2,1,1);imshow(A); t = linspace(0, 1, 256); map = t.^2; z = intxform(A, map);subplot(2,1,2);imshow(z); 结果:
3.5 、代码
function w = genlaplacian(n) if ~isinteger1(n) | n
center = (n^2)imfilter(fd, genlaplacian(3), \'replicate\'); g5 = fdimfilter(fd, genlaplacian(9), \'replicate\'); g15 = fdimfilter(fd, genlaplacian(25), \'replicate\'); subplot(2,3,1);imshow(fd);title(\'a\'); subplot(2,3,2);imshow(g3);title(\'b\'); subplot(2,3,3);imshow(g5);title(\'c\'); subplot(2,3,4);imshow(g9);title(\'d\'); subplot(2,3,5);imshow(g15);title(\'e\'); subplot(2,3,6);imshow(g25);title(\'f\'); 结果:
《数字图像处理》实验报告
3.6 代码:
w = fspecial(\'unsharp\', 0); f = imread(\'Fig0217(a).tif\'); imshow(f) g = imfilter(f, w, \'replicate\'); figure, imshow(g)
结果
七、本实验的心得体会
通过本实验的学习与实践,我学到了很多图像处理的技巧,掌握图像增强的基本原理与实现方法,掌握基本的空间域操作,也对学习图像处理产生了更多的兴趣。