Re: How to combine 3 grayscale images into one RGB color image ?
- To: mathgroup at smc.vnet.net
- Subject: [mg69609] Re: [mg69555] How to combine 3 grayscale images into one RGB color image ?
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sun, 17 Sep 2006 06:57:57 -0400 (EDT)
- Reply-to: hanlonr at cox.net
I don't understand mixing colors so this probably isn't right, but it may get you started. Needs["Graphics`"]; nr=5;nc=4; r=Table[Random[],{nr},{nc}]; g=Table[Random[],{nr},{nc}]; b=Table[Random[],{nr},{nc}]; Clear[clr]; clr[c_Integer/;0<c<=nr*nc]:=Module[{ m=Floor[(c-1)/nc]+1, n=Mod[c-1,nc]+1}, RGBColor[r[[m,n]],g[[m,n]], b[[m,n]]]]; DisplayTogetherArray[{{ DensityGraphics[r], DensityGraphics[r, ColorFunction->(RGBColor[#, 0, 0]&), Mesh->False]}, {DensityGraphics[g], DensityGraphics[g, ColorFunction->(RGBColor[0, #, 0]&), Mesh->False]}, {DensityGraphics[b], DensityGraphics[b, ColorFunction->(RGBColor[0, 0, #]&), Mesh->False]}, {DensityGraphics[(r+g+b)/3], DensityGraphics[Table[nc*(r-1)+c,{r,nr},{c,nc}], ColorFunction->(clr[#]&), ColorFunctionScaling->False, Mesh->False]}}, ImageSize->300]; Bob Hanlon ---- mario.ivanov at risoe.dk wrote: > How to combine 3 grayscale images into one RGB color image ? > > I have 3 "DensityGraphics" pictures and I want to combine them in > such a way that the one represents the Red, the others - green and blue > colors correspondingly. > This procedure is called "merge channels" in Photoshop. > > It must be quite easy to solve that even without external packages, but > I am not experienced enough. > > Thank you. >