Reputation: 133
To get RGB values:
RGB = imread('C:\Documents and Settings\student2\Desktop\Water lilies.jpg');
R = RGB(:, :, 1);
G = RGB(:, :, 2);
B = RGB(:, :, 3);
Can someone tell me why we use 1, 2, and 3 to get Red, Green, and Blue matrices respectively?
Upvotes: 3
Views: 2351
Reputation: 4388
If you look at the size of RBG: size(RGB)
, you will see that it is width X height X 3. Each pixel is represented by 3 values - red, green, and blue; the actual colour of the pixel is a mixture of these primary colour - Wikipedia.
If you want to know the reason why R is 1, G is 2 and B is 3, rather than R being 3 and B being 1 or something, it is just convention. I assume because red light is a lower frequency of light, blue is higher and green is in between - Wikipedia.
Upvotes: 3