3
$\begingroup$

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.

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

1 Answer 1

3
$\begingroup$

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:

enter image description here

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

$\endgroup$
6
  • $\begingroup$ These examples are for red/cyan only. I need for red/blue as well. $\endgroup$
    – neutrino
    Commented Dec 5, 2017 at 0:47
  • $\begingroup$ Easy, just change to {imgd, 3} in the code $\endgroup$ Commented Dec 5, 2017 at 6:41
  • $\begingroup$ 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. $\endgroup$
    – neutrino
    Commented Dec 5, 2017 at 12:16
  • $\begingroup$ 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... $\endgroup$ Commented Dec 5, 2017 at 12:29
  • $\begingroup$ Only Red/Blue were available at nearby shop and i was eager to test them. $\endgroup$
    – neutrino
    Commented Dec 5, 2017 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.