imread
:读取图像imread(图像文件路径(包含名称))
subplot
:图像分区显示subplot(x行,y列,第n个)
imshow
:图像展示imshow(图像变量/图像文件路径)
imwrite
:图像输出imwrite(图像变量,输出的文件路径(包含名称),'quality',输出质量(0~100))
代码:
%% 清理工作区
clc;
clear;
close all;
f=imread('1.tif'); % 图像读入
%% 图像分区显示
subplot(2,2,1);imshow(f); % 原图
redf=f;
redf(:,:,2:3)=0; % 将G、B通道置零
subplot(2,2,2);imshow(redf); % 红色通道R
greenf=f;
greenf(:,:,1)=0;
greenf(:,:,3)=0; % 将R、B通道置零
subplot(2,2,3);imshow(greenf); % 绿色通道G
bluef=f;
bluef(:,:,1:2)=0; % 将R、G通道置零
subplot(2,2,4);imshow(bluef); % 蓝色通道B
%% 图像输出为jpg格式
imwrite(f,'存储质量10.jpg','quality',10);
imwrite(f,'存储质量50.jpg','quality',50);
imwrite(f,'存储质量80.jpg','quality',80);