前言
正文
clc;
clear;
close all;
a=imread('che.png');
%提取图像三通道信息
channel_R=a;
channel_G=a;
channel_B=a;
%分别让3个通道的值=0,提取出R、G、B通道
%R
channel_R(:,:,2)=0;
channel_R(:,:,3)=0;
gray_R=rgb2gray(channel_R);%转成灰度值
bin_R=dec2bin(gray_R');%转成二进制
dlmwrite('E:\FPGA\picture_tuuuuu\che_R.txt',bin_R,'delimiter','','newline','pc');
%G
channel_G(:,:,1)=0;
channel_G(:,:,3)=0;
gray_G=rgb2gray(channel_G);
bin_G=dec2bin(gray_G');
dlmwrite('E:\FPGA\picture_tuuuuu\che_G.txt',bin_G,'delimiter','','newline','pc');
%B
channel_B(:,:,1)=0;
channel_B(:,:,2)=0;
gray_B=rgb2gray(channel_B);
bin_B=dec2bin(gray_B');
dlmwrite('E:\FPGA\picture_tuuuuu\che_B.txt',bin_B,'delimiter','','newline','pc');
% 显示图像
subplot(2,2,1);
imshow(channel_R,[]);
title('R通道');
subplot(2,2,2);
imshow(channel_G,[]);
title('G通道');
subplot(2,2,3);
imshow(channel_B,[]);
title('B通道');
subplot(2,2,4);
imshow(a,[]);
title('原图');