In this example, we will demonstrate the usage of inherent MATLAB functions to transform a RGB image to HSV and to CIE-L*a*b*. For the first one, we will use rgb2hsv
and for the second one we will use makecform
and applycform
. The following steps will do the trick:
First we load our image:
>> img = imread('my_image_color.bmp');
Then, we generate the HSV image:
>> img_hsv = rgb2hsv(img);
Finally, we will convert our image to CIE-L*a*b*:
>> cform = makecform('srgb2lab'); % Make the transformstructure >> img_lab = applycform(img,cform); % Apply transform
Now, let's demonstrate our results:
>> subplot(3,4,1),imshow(img),title('RGB image') >> subplot(3,4,2),imshow(img(:,:,1)),title('R channel') >> subplot(3,4,3),imshow(img(:,:,2)),title('G channel') >> subplot(3,4,4),imshow(img(:,:,3)),title('B channel') >> subplot(3,4,5),imshow(img_hsv),title('HSV image') >> subplot(3,4,6),imshow(img_hsv(:,:,1))...