对图片的RGB三种颜色进行提取:分量提取以及相应的基础形式的变换。
代码如下:
clear all;clc;close all;
I001=imread('sfrggtth.jpg');
J001=rgb2gray(I001);%转换为灰度图
J002=im2bw(J001);
subplot(321);imshow(I001);title('原始图像');
subplot(322);imshow(J001);title('灰度图像');
subplot(323);imshow(J002);title('二值图像');
K001R=I001(:,:,1);
K001G=I001(:,:,2);
K001B=I001(:,:,3);%提取图像像素矩阵分析分量
subplot(324);imshow(K001R);title('红色图像');
subplot(325);imshow(K001G);title('绿色图像');
subplot(326);imshow(K001B);title('蓝色图像');
效果如图: