This time we will perform color isolation for our lake fence photograph, using just channel a*. The goal will remain at converting the whole image to grayscale, except the fence tips that should remain red. For comparison purpose, we will also perform the RGB process. We will follow these steps:
First, we will load the image and generate the same mask as before, using thresholding, cleaning, and dilation:
>> img = imread('my_image_color.bmp'); >> [output2] = RGBThreshold(img,[160 130 130]); >> output(1:100,:) = 0; >> maskRGB = imdilate(output2,strel('disk', 2));
Let's produce the mask using CIE-L*a*b* color space:
>> cform = makecform('srgb2lab'); % Make the transform structure >> img_lab = applycform(img,cform); % Apply transform >> maskLab = (img_lab(:,:,2) > 150); % Threshold a* channel
Then, we separate the color channels:
>> R = img(:,:,1); % store R channel in new matrix >> G = img...