# How to generate image/plot for view in red/blue 3d glasses?

How to modify code in post Is it possible to produce anaglyphs with Mathematica? to view image from red/blue glasses?

Frankly i did not understand how ColorConvert and ColorCombine functions were used. Mathematica offers little guide relating to manipulating color channels.

• What kind of image? I assume you have a 3d Image? Dec 4, 2017 at 14:22
• What kind of modification do you have in mind? You'll get better help the more specific you are.
– JimB
Dec 4, 2017 at 14:28
• L/R perspective of the same scene and color coded according to Red/Blue or Red/cyan. Dec 4, 2017 at 18:44
• Possible duplication of mathematica.stackexchange.com/questions/9327/… Dec 4, 2017 at 19:46

I have tried with this after my post in the link you provide:

photoanaglyph[imgi_, imgd_] :=
ColorCombine[
Flatten@(ColorSeparate[#[[1]]][[#[[2]]]] & /@ {{imgi, 1}, {imgd, 2 ;; 3}})]


and it works fine. I have been able to create some good (even better) images, such as:

Of course it is assumed that you have two images (left, right) having different perspectives, and having a good alignment.

• These examples are for red/cyan only. I need for red/blue as well. Dec 5, 2017 at 0:47
• Easy, just change to {imgd, 3} in the code Dec 5, 2017 at 6:41
• p = Plot3D[Sin[x y]^2, {x, -2, 2}, {y, -2, 2}]; {r, g} = ColorConvert[ Image[Show[p, ViewPoint -> {3 Sin[#], 3 Cos[#], 2} &[# Degree]], ImageSize -> {360, 275}], "RGB"] & /@ {141, 139} photoanaglyph[imgi_, imgd_] := ColorCombine[ Flatten@(ColorSeparate[#[[1]]][[#[[2]]]] & /@ {{imgi, 1}, {imgd, 3}})] photoanaglyph[r, g]. I obtain a colour less output. What am i doing wrong here. Dec 5, 2017 at 12:16
• You have to combine three grayscale images. The process treat each image as a single array. If you have only two of them you need a third one having zeros to combine only red and blue channels (as green should be a zero array having the same dimensions of the images). As an additional information, I do no know why you have a red-blue image. Conventional red-blue glasses are not red-blue, but a red-cyan. Maybe, I am missing something... Dec 5, 2017 at 12:29
• Only Red/Blue were available at nearby shop and i was eager to test them. Dec 5, 2017 at 13:08