Follow this link and you can experiment the RGB format and the colors that it gives for different values:
RGB color tester.
%clear everything previous
clear all;
% read image from desktop ,enter your path and an image
rgbImage = imread('c:/users/cex/desktop/color.jpg');
% display original image in the first figure (array of figures 2x2)
subplot(2,2, 1);
imshow(rgbImage);
title('Original RGB Image');
% split the image into the three color bands
redBand = rgbImage(:,:, 1);
greenBand = rgbImage(:,:, 2);
blueBand = rgbImage(:,:, 3);
% Maximize the window of figures
set(gcf, 'Position', get(0, 'ScreenSize'));
%RED DETECTION
redthreshold = 100;
greenThreshold =100;
blueThreshold = 100;
redMask = (redBand > redthreshold);
greenMask = (greenBand < greenThreshold);
blueMask = (blueBand < blueThreshold);
% Combine the masks to find where all 3 are "true"
redObjectsMask = uint8(redMask & greenMask & blueMask);
% Initialize to black
maskedrgbImage = uint8(zeros(size(redObjectsMask)));
maskedrgbImage(:,:,1) = rgbImage(:,:,1) .* redObjectsMask;
maskedrgbImage(:,:,2) = rgbImage(:,:,2) .* redObjectsMask;
maskedrgbImage(:,:,3) = rgbImage(:,:,3) .* redObjectsMask;
subplot(2, 2, 2);
imshow(maskedrgbImage);
title('Red');
%GREEN DETECTION
% Threshold each color band.
redthreshold = 100;
greenThreshold =100;
blueThreshold = 100;
redMask = (redBand < redthreshold);
greenMask = (greenBand > greenThreshold);
blueMask = (blueBand < blueThreshold);
% Combine the masks to find where all 3 are "true."
greenObjectsMask = uint8(redMask & greenMask & blueMask);
% Initialize to black
maskedrgbImage = uint8(zeros(size(greenObjectsMask)));
maskedrgbImage(:,:,1) = rgbImage(:,:,1) .* greenObjectsMask;
maskedrgbImage(:,:,2) = rgbImage(:,:,2) .* greenObjectsMask;
maskedrgbImage(:,:,3) = rgbImage(:,:,3) .* greenObjectsMask;
subplot(2, 2, 3);
imshow(maskedrgbImage);
title('Green');
%BLUE DETECTION
redthreshold = 100;
greenThreshold =100;
blueThreshold = 100;
redMask = (redBand < redthreshold);
greenMask = (greenBand < greenThreshold);
blueMask = (blueBand > blueThreshold);
% Combine the masks to find where all 3 are "true."
blueObjectsMask = uint8(redMask & greenMask & blueMask);
% Initialize to black
maskedrgbImage = uint8(zeros(size(blueObjectsMask)));
maskedrgbImage(:,:,1) = rgbImage(:,:,1) .* blueObjectsMask;
maskedrgbImage(:,:,2) = rgbImage(:,:,2) .* blueObjectsMask;
maskedrgbImage(:,:,3) = rgbImage(:,:,3) .* blueObjectsMask;
subplot(2, 2, 4);
imshow(maskedrgbImage);
title('Blue');