MATLAB Answers


how to read the color image with combined the R,G,B component ?

Asked by preet
on 20 Apr 2013

i have a color image like baby.tif when i use a statement as below


in imData array R,G,B component store separate


imData(:,:,1)% red



imData(:,:,2) %green





imData(:,:,3) % blue



like this but i need all component combined for single pixel example for first pixel i have value for r,g,b (13,16,17) then second and so on if my image size 60*60 then to represent the color value in 60*180 size in array


What form do you need them? As I see it, you already have the RGB values in the most useful and convenient form. What do you want that's different than that? Do you want it in this inconvenient form: [r1, g1, b1, r2, g2, b2, r3, g3, b3, r4, g4, b4, .....] where it's just one long interleaved 1 dimensional array? If so, why - what would you do with that?

on 20 Apr 2013

actually i write the color values of 1000 images in a single .txt file. so when i read that txt file its not easy to read sepratly each component for 1000 images

Well . . . . don't do that! You already had the color values in the original format image files.



No products are associated with this question.

1 Answer

Answer by Walter Roberson
on 20 Apr 2013
 Accepted answer

reshape( permute(imData, [1 3 2]), size(imData,1), size(imData,2) * size(imData,3) )


on 21 Apr 2013

Thanx sir, as usually u r gv me ans.

Actually you've only accepted one other of his answers that he spent time giving you. If what you say is true, then you should go back and accept his other answers also.

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!