用MATLAB对图像进行采样处理
一、实验目的:掌握图像采样原理
二、实验内容:试对512x512的lenagray.jpg图像分别采样为256x256、128x128、64x64的图像,观察图像质量的变化
第一幅图是原图,第二幅是不同采样程度的对应图像
代码如下所示:
%将界面上的内容全部清空
clc;
clear;
close all;
I1=imread('D:/Mypicture/lenagray.jpg');%将磁盘存放的图片读入程序
I2=I1(1:2:end,1:2:end);%每2位采集1位
I3=I1(1:4:end,1:4:end);%每4位采集1位
I4=I1(1:8:end,1:8:end);%每8位采集1位
%显示图片
figure;
subplot(2,2,1),imshow(I1),title('512X512');
subplot(2,2,2),imshow(I2),title('256X256');
subplot(2,2,3),imshow(I3),title('128X128');
subplot(2,2,4),imshow(I4),title('64X64');