from
COLOR SYSTEMS
by Divakar Roy
Convert color images between RGB,RBG,GRB,GBR,BRG,BGR
|
| colsys(input_image, color_system, output_image)
|
% COLOR SYSTEM : Changes the color system from the rgb to other 5 systems
%
% Syntax: colsys(input_image_name, color_system, output_image_name)
% Color Systems : rgb2rbg, rgb2grb, rgb2gbr, rgb2brg, rgb2bgr
% Example: colsys('Input.jpg','rgb2bgr','Output.jpg');
function colsys(input_image, color_system, output_image)
switch(color_system)
case ('rgb2rbg')
color_mode=1;
case ('rgb2grb')
color_mode=2;
case ('rgb2gbr')
color_mode=3;
case ('rgb2brg')
color_mode=4;
case ('rgb2bgr')
color_mode=5;
end
img=imread(input_image);
[m1 n1 r1]=size(img);
dion=[1 3 2;2 1 3;2 3 1;3 1 2;3 2 1];
image1=zeros(m1,n1,r1);
image1(:,:,:)=img(:,:,dion(color_mode,:));
image1=uint8(image1);
imwrite(image1,output_image);
|
|
Contact us at files@mathworks.com