Understanding Primary and Secondary Colors, RGB, and Image Manipulation with MATLAB
Understanding Primary and Secondary Colors
What is the nearest primary or secondary color of the following color combinations? State whether the color is a primary or secondary color.
RGB(95, 98, 60) – No dominant primary colors here, therefore – Secondary
RGB(125, 244, 250) – Secondary
RGB(10, 100, 90) – Secondary
RGB(80, 98, 60) – Secondary
RGB(240, 10, 15) – Primary
Explain what primary and secondary colors are and provide answers accordingly.
Primary Colors:
Red
Green
Blue
Secondary Colors:
- Red + Blue gives magenta
- Green + Blue gives cyan
- Red + Green gives yellow
- Calculate hue and saturation for the above RGB values.
Saturation:
If a color contains only one or two primary colors, it is said to be fully (100%) saturated.
Microsoft Saturation
To find the Microsoft equivalent, multiply the answer by 0.667.
- Calculate hue and saturation for the above RGB values using the way used in Microsoft Paint.
MATLAB Image Manipulation
Construct and write down the MATLAB commands to do the following:
- Fill a grayscale array to represent an image of size 320w x 240h
- Display the image.
- Increase the array values by 50, explain what happens to the image in general.
- Crop a 100×100 form the image as below:
- From the top left corner
- From the middle of the image
- From the top right corner.
- Write the content of the gray array to a file.
- Repeat the above steps to represent a color image.
NB: You should use the minimum commands as possible to perform these operations.
a) Fill a grayscale array to represent an image of size 320w x 240h
myGreyArray=zeros(320, 240);
b) Display the image.
image(myGreyArray);
c) Increase the array values by 50, explain what happens to the image in general.
myGreyArray(:, :)=50;
% The color of the image would be a lighter grey
d) Crop a 100×100 from the image as below:
a. From the top left corner
b. From the middle of the image
c. From the top right corner.
a. cropMyGreyArray=myGreyArray(1:100, 1:100);
b. cropMyGreyArray=myGreyArray((320/2)-50:(320/2)+50, (240/2)-50):(240/2)+50));
c. cropMyGreyArray=myGreyArray(220:320, 140:240);
e) Write the content of the gray array to a file.
imwrite(myGreyArray, ‘myGreyArray.jpg’)
from the middle
f) Repeat the above steps to represent a color image.
g) Fill a color array to represent an image of size 320w x 240h
myColourArray=zeros(320, 240, 3);
h) Display the image.
image(myColourArray);
i) Increase the array values by 50, explain what happens to the image in general.
myGreyArray(:, :, 50)+50;
% The color of the image would be grey
j) Crop a 100×100 from the image as below:
a. From the top left corner
b. From the middle of the image
c. From the top right corner.
a. cropMyColourArray=myColourArray(0:100, 0:100, :);
b. cropMyColourArray=myColourArray((320/2)-50:(320/2)+50, (240/2)-50):(240/2)+50), :);
c. cropMyColourArray=myColourArray(220:320, 140:240, :);
k) Write the content of the gray array to a file.
imwrite(myColourArray, ‘myColourArray.jpg’)
//////////////////////////////////////////