Saul_goodman
Saul_goodman

Reputation: 141

Difficulty in getting the matrix of red, green,blue

 a = imread('Sample1.jpg');
 imshow(a)

This gives me the image but my problem is stated as below

It happens that I have an image in RGB format then how to get 3 different matrix of red ,green,blue respectively in Mat lab , I have also searched the documentation but can't get satisfactory reply , I also want to store this values.

Upvotes: 0

Views: 60

Answers (1)

rayryeng
rayryeng

Reputation: 104464

Using imread produces a 3 slice matrix, so accessing red, green and blue individually is simply:

R = a(:,:,1);
G = a(:,:,2);
B = a(:,:,3);

You use the third dimension of a to get the colour channel you want. They are ordered as red, green and blue respectively (hence RGB).

Upvotes: 4

Related Questions