Page 1 of 1
How to make grayscale anaglyph (stereo) image
Posted: 2013-04-16T03:54:17-07:00
by l.a.rabida
Hi all,
I'm trying to make a grayscale anaglyph image. According to
http://arachnoid.com/raytracing/anaglyphic_3d.html, it should work like this:
convert -colorspace gray "left.jpg" "gleft.jpg"
convert -colorspace gray "right.jpg" "gright.jpg"
composite -stereo 0 "gleft.jpg" "gright.jpg" 3d.jpg
But all I get is a completely grayscale output image. I'm not sure if this is a bug or if I'm doing something wrong.
Strangely, using color input does create a color anaglyph:
composite -stereo 0 "left.jpg" "right.jpg" 3d.jpg
I'm using:
Version: ImageMagick 6.7.7-10 2012-08-17 Q16
http://www.imagemagick.org
on Ubuntu (Xubuntu) 12.10.
Thanks in advance for your answer(s)!
Re: How to make grayscale anaglyph (stereo) image
Posted: 2013-04-16T09:31:49-07:00
by el_supremo
You should be able to create the anaglyph with one command. The -stereo option handles the selection of the correct channels.
Code: Select all
composite left.jpg right.jpg -stereo 0 3d.jpg
Pete
Re: How to make grayscale anaglyph (stereo) image
Posted: 2013-04-16T10:43:58-07:00
by l.a.rabida
Thanks for your reply. I just tried the command you gave, and it works, but it creates a colored anaglyph image, not a black and white one. When looking to red/blue glasses, colored anaglyphs are not as pretty as black and white (grayscale) ones. So how should I create grayscale ones? It should be possible according to the website I've given, but the output I get is entirely grayscale, without the red/blue shift.
Re: How to make grayscale anaglyph (stereo) image
Posted: 2013-04-16T11:42:05-07:00
by fmw42
That link is creating a colored anaglyph image. Their code is wrong any way, since in IM the input image should be read first and then follow that with -colorspace gray. In more current IM versions, you would likely need to use -set colorspace RGB -colorspace gray
convert leftimage -set colorspace RGB -colorspace gray leftgrayimage
convert rightimage -set colorspace RGB -colorspace gray rightgrayimage
composite -stereo +X leftgrayimage rightgrayimage anaglyphimage
Note, that unless you have created two colored images with stereo offsets in some 3D package or captured two images from shifted vantage points, you must then set an offset using +X, since that is the same image you are using in both cases.
The process of combining them into an anaglyph puts one grayscale image in the red channel and the other grayscale image in the green and blue channels so that you have a red-cyan (colored) anaglyph image.
There is no such thing as a grayscale anaglyph. Anaglyph by definition means color. See
http://en.wikipedia.org/wiki/Anaglyph_3D The only way to avoid the coloring process is to use polarize glasses or shuttered glasses. Then the two grayscale or color images can be used. But that cannot be done in Imagemagick.
Re: How to make grayscale anaglyph (stereo) image
Posted: 2013-04-16T12:47:01-07:00
by l.a.rabida
Thanks for your reply. By "grayscale anaglyph" I mean an anaglyph that is created from two monochrome source images.
I exactly tried your code:
convert leftimage -set colorspace RGB -colorspace gray leftgrayimage
convert rightimage -set colorspace RGB -colorspace gray rightgrayimage
composite -stereo +X leftgrayimage rightgrayimage anaglyphimage
But the resulting "anaglyphimage" is
entirely monochrome, there isn't any blue or red in it.
The site
http://arachnoid.com/raytracing/anaglyphic_3d.html gives an example of an anaglyph that is created from two monochrome sources, and this should work with ImageMagick to.
So is this a bug or am I still missing something?
Re: How to make grayscale anaglyph (stereo) image
Posted: 2013-04-16T13:01:33-07:00
by fmw42
What version of IM are you using and what platform. The following works perfectly fine for me on IM 6.8.4.10 Q16 Mac OSX Snow Leopard.
convert lena.jpg -set colorspace RGB -colorspace gray lena_left.png
convert lena.jpg -set colorspace RGB -colorspace gray lena_right.png
composite -stereo +10 lena_left.png lena_right.png lena_anaglyph.png
Note the above two left/right grayscale images are the same and thus -stereo needs the +10 or whatever you want to use. If you have two images that are taken separately with an offset in position (but not a change in viewing direction), then you can set the +X to +0, because you have a real stereo pair and not just faking it as above.
Re: How to make grayscale anaglyph (stereo) image
Posted: 2013-04-17T03:30:14-07:00
by l.a.rabida
Thanks for your help! There isn't a PPA available (anymore) for Ubuntu, so I installed the latest version (6.8.4-10 2013-04-13 Q16) of ImageMagick via Wine (that is, the Windows version). Now it does work properly, so I guess it was a bug in the previous version. I've included the version information in my first post.
Thanks again for your answers.