MATLAB: How to extract RGB values of each pixel from an image

image processingMATLAB

I need to extract the RGB values of each pixel of a given image in a serial data format like R1:G1:B1, R2:G2:B2, R3:G3:B3… and so on.

Best Answer

Try this:
rgbImage = permute(rgbImage, [3,1,2])
serialValues = rgbImage(:)'
This will give you [r1,g1,b1, r2,g2,b2, r3,g3,b3, r4,g4,b4, ...] which is a row vector taken from the original RGB image in column major order.
Related Question