How to separate RGB values of an image?

Illustration
Jessica - 2020-09-30T09:50:36+00:00
Question: How to separate RGB values of an image?

We know that each pixel i in the input image I has rgb colors. My question is how to store them in a 3-vector Ii. Each color is being represented using a 64-bit floating-point number scaled to between 0 and 1.

Expert Answer

Profile picture of Prashant Kumar Prashant Kumar answered . 2025-11-20

Sean de has told you how to get each plane, but it sounds like you want some kind of vector. I am not sure what you mean by a 3 vector, but here are a couple of guesses.
If you want 3 vectors:
 
R = reshape(I(:,:,1),[],1);
G = reshape(I(:,:,2),[],1);
B = reshape(I(:,:,3),[],1);

Now if you want them all together in a 3 column vector:

V3 = reshape(A(:),[],3) % R is first col, G is second col, B is third.


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!