开发语言 计算机视觉 四、数字图像处理Matlab实验 第二章 数字图像基础 - tif&#39

📅 2026-11-30 👤 拼多多助力营销技巧 📂 拼多多助力平台 👁️ 248 次阅读

开发语言 计算机视觉 四、数字图像处理Matlab实验 第二章 数字图像基础

文章目录

一、使用不同空间分辨率显示图片 P351.1 实验内容1.2 文件目录1.3 Matlab代码1.4 实验结果

二、使用不同灰度分辨率显示图片 P352.1 实验内容2.2 文件目录结构2.3 Matlab代码2.4 实验结果

三、使用三种插值法实现图像缩放 P383.1 实验内容3.2 文件目录结构3.3 Matlab代码3.4 实验结果

四、算术操作:带噪图像相加(平均)降噪 P444.1 实验内容4.2 文件目录结构4.3 Matlab代码4.4 实验结果

五、算术操作:增强差别的图像相减 P455.1 实验内容5.2 文件目录结构5.3 Matlab代码5.4 实验结果

六、算术操作:使用图片相乘和相除 P456.1 实验内容6.2 文件目录结构6.3 Matlab代码6.4 实验结果

实验所用教材配图资源:数字图像处理-冈萨雷斯-第三版(教材配图) 实验Matlab代码资源:数字图像处理 第二章 数字图像基础(Matlab实验代码)

一、使用不同空间分辨率显示图片 P35

1.1 实验内容

使用不同空间分辨率显示图片

1.2 文件目录

1.3 Matlab代码

% 显示不同空间分辨率的图像

% 清除所有之前的数据

close all;clear all;clc

% 1、导入1250dpi的原图片

img_1250 = imread('Fig0220(1250dpi).tif');

% 4、读入不同分辨率的图片

img_300 = imread('Fig0220(300dpi).tif');

img_150 = imread('Fig0220(150dpi).tif');

img_72 = imread('Fig0220(72dpi).tif');

% 5、创建一个图像层

figure(1);

% 6、依次在4个分隔区中显示上述图片

subplot(1,4,1);

imshow(img_1250);

title('1250 dpi');

subplot(1,4,2);

imshow(img_300);

title('300 dpi');

subplot(1,4,3);

imshow(img_150);

title('150 dpi');

subplot(1,4,4);

imshow(img_72);

title('72 dpi');

1.4 实验结果

同一图片不同空间分辨率的显示

二、使用不同灰度分辨率显示图片 P35

2.1 实验内容

使用不同灰度分辨率(255,128,64,32,16,8,4,2)显示图片

2.2 文件目录结构

2.3 Matlab代码

% 显示不同灰度级显示同一图像

close all;clear all;clc;

% 读入图片

in = imread('Fig0221(ctskull-256).tif');

% 显示图像

figure;

L=256;

for i = 1:8

subplot(2,4,i);

if i ~= 1

in = idivide(in,2);

end

imshow(in,[0 L-1]);

title(['灰度值为',num2str(L),'的图像']);

L = L / 2;

end

2.4 实验结果

同一图片不同灰度分辨率的显示

三、使用三种插值法实现图像缩放 P38

3.1 实验内容

编写Matlab代码实现不同空间分辨率的图像的缩放。主要使用 最近邻内插法、双线性内插法、双三次内插法

3.2 文件目录结构

3.3 Matlab代码

% 使用最近邻域插值、双线性插值、双三次插值缩放图片的实验 P38

close all;clear all;clc

% 导入72dpi的图

img_72 = imread('Fig0220(72dpi).tif');

% 导入150dpi的图

img_150 = imread('Fig0220(150dpi).tif');

% 第一、二组计算切换标志

% 使用72dpi的原图

% ①使用最近邻域法扩大至原图大小

img_nearest_72 = imresize(img_72,1250 / 72,'Method','nearest');

% ②使用双线性插值法扩大至原图大小

img_bilinear_72 = imresize(img_72,1250 / 72,'Method','bilinear');

% ③使用双三次插值法扩大至原图大小

img_bicubic_72 = imresize(img_72,1250 / 72,'Method','bicubic');

% 使用150dpi的原图

% ①使用最近邻域法扩大至原图大小

img_nearest_150 = imresize(img_150,1250 / 150,'Method','nearest');

% ②使用双线性插值法扩大至原图大小

img_bilinear_150 = imresize(img_150,1250 / 150,'Method','bilinear');

% ③使用双三次插值法扩大至原图大小

img_bicubic_150 = imresize(img_150,1250 / 150,'Method','bicubic');

figure;

subplot(1,3,1),

imshow(img_nearest_72);

title("72dpi,最近邻内插法放大至原图大小");

subplot(1,3,2),

imshow(img_bilinear_72);

title("72dpi,双向性内插法放大至原图大小");

subplot(1,3,3),

imshow(img_bicubic_72);

title("72dpi,双三次内插法放大至原图大小");

figure;

subplot(1,3,1),

imshow(img_nearest_150);

title("150dpi,最近邻内插法放大至原图大小");

subplot(1,3,2),

imshow(img_bilinear_150);

title("150dpi,双向性内插法放大至原图大小");

subplot(1,3,3),

imshow(img_bicubic_150);

title("150dpi,双三次内插法放大至原图大小");

3.4 实验结果

72dpi的图像 使用三种插值方法进行放大

150dpi的图像 使用三种插值方法进行放大

四、算术操作:带噪图像相加(平均)降噪 P44

4.1 实验内容

依次将加有高斯噪声的5,10,20,50,100,相加平均后降噪

4.2 文件目录结构

4.3 Matlab代码

% 针对降噪的带噪图像的相加平均实验 P43

close all;clear all;clc;

% 读入图像

in = imread('Fig0226(galaxy_pair_original).tif'); 拼多多帮助力入口

% 创建100幅加高斯噪声的图像

s_5 = int32(in);

s_10 = int32(in);

s_20 = int32(in);

s_50 = int32(in);

s_100 = int32(in);

[r,c] = size(in);

img_noise = int32(zeros(r,c));

for i = 1:100

img_noise = int32(imnoise(in,'gaussian',0,0.1));

s_100 = s_100 + img_noise;

if i <= 50

s_50 = s_50 + img_noise;

end

if i <= 20

s_20 = s_20 + img_noise;

end

if i <= 10

s_10 = s_10 + img_noise;

end

if i <= 5

s_5 = s_5 + img_noise;

end

end

% 显示图片

figure;

subplot(2,3,1);

imshow(mat2gray(img_noise));

title('被加高斯噪声污染的星系NGC 3314');

subplot(2,3,2);

imshow(mat2gray(s_5 ./ 5));

title('对5幅图噪声图像平均的结果');

subplot(2,3,3);

imshow(mat2gray(s_10 ./ 10));

title('对10幅图噪声图像平均的结果');

subplot(2,3,4);

imshow(mat2gray(s_20 ./ 20));

title('对20幅图噪声图像平均的结果');

subplot(2,3,5);

imshow(mat2gray(s_50 ./ 50));

title('对50幅图噪声图像平均的结果');

subplot(2,3,6);

imshow(mat2gray(s_100 ./ 100));

title('对100幅图噪声图像平均的结果');

4.4 实验结果

累加m幅带有高斯噪声的图片再求平均值后的降噪

五、算术操作:增强差别的图像相减 P45

5.1 实验内容

将指定的两幅图像相减,得到增强后的差别部分

5.2 文件目录结构

5.3 Matlab代码

实验一的代码

% 对于增强差别的图像相减的实验 P44(1)

close all;clear all;clc;

% 读入图片

in = imread('Fig0227(washington_infrared).tif');

% 执行图像相减的操作

L = 256;

[row,column] = size(in);

s_low_reduce = in;

for r = 1:row

for c = 1:column

if mod(s_low_reduce(r,c),2) % 判断最低比特位是否为1

s_low_reduce(r,c) = s_low_reduce(r,c) - 1; % 判断最低比特位置零

end

end

end

% 显示图片

figure;

subplot(1,3,1);

imshow(in,[0 255]);

title('(a)华盛顿特区的红外线图像');

subplot(1,3,2);

imshow(s_low_reduce,[0 255]);

title('(b)将图像(a)中的每个最低阶比特置0得到图像');

subplot(1,3,3);

% 结果标定到[0 255]中

result = in - s_low_reduce;

result = result - min(result);

result = (L-1) * result ./ max(result);

imshow(result);

title('(c)两幅图像的差,为清楚旗舰,图像已标定为[0,255]');

实验二的代码

% 对于增强差别的图像相减的实验 P44(2)

close all;clear all;clc;

% 读入图片

in_mask = imread('Fig0228(angiography_mask_image).tif');

in_live = imread('Fig0228(angiography_live_ image).tif');

% 做差值

s_reduce = in_mask - in_live;

% 对差值做增强

L = 256;

c = (L-1)/log(L-1);

s_reduce_augment = c * log(double(s_reduce) + 1);

% 显示图像

figure;

subplot(1,4,1);

imshow(in_mask);

title('(a)模板图像');

subplot(1,4,2);

imshow(in_live);

title('(b)活体图像');

subplot(1,4,3);

imshow(mat2gray(s_reduce));

title('(c)图(a)和图(b)的差值图像');

subplot(1,4,4);

imshow(mat2gray(s_reduce_augment));

title('(d)增强后的差值图像(采用对数变换增强)');

5.4 实验结果

实验一结果图

实验二结果图

六、算术操作:使用图片相乘和相除 P45

6.1 实验内容

实验①图片相乘、除达到去阴影的效果 试验②图片相乘实现ROI

6.2 文件目录结构

6.3 Matlab代码

实验一的代码

% 使用图像相乘和相除来校正阴影 P45

close all;clear all;clc;

% 读入图像

in = imread('Fig0229(tungsten_filament_shaded).tif');

in_shadow = imread('Fig0229(tungsten_sensor_shading).tif');

s = double(in) .* (1.0 ./ double(in_shadow));

% 显示图像

figure;

subplot(1,3,1);

imshow(in);

title('(a)钨丝及其支撑物的阴影SEM图像,改图像放大了近130倍');

subplot(1,3,2);

imshow(in_shadow);

title('(b)阴影模式');

subplot(1,3,3);

imshow(mat2gray(s));

title('(c)图(b)的倒数与图(a)相乘的结果');

实验二的代码

% 对感兴趣的区域的ROI操作 P46

close all;clear all;clc;

% 读入图像

in_mask = imread('Fig0230(dental_xray_mask).tif');

in = imread('Fig0230(dental_xray).tif');

% 显示图像

figure;

subplot(1,3,1);

imshow(in);

title('(a)牙齿的X射线数字图像');

subplot(1,3,2);

imshow(in_mask);

title('(b)使用填充物隔离牙齿的ROT模板');

subplot(1,3,3);

in_mask(in_mask > 0) = 1;

imshow(mat2gray(in .* in_mask));

title('(c)图(a)和图(b)相乘的结果');

6.4 实验结果

实验一的结果

实验二的结果

开发语言 计算机视觉 四、数字图像处理Matlab实验 第二章 数字图像基础

推荐阅读

标签: 拼多多助力网站平台 赚钱项目 拼多多助力网 首码项目 手赚APP
拼多多助力营销技巧