Page 1 of 1
anaglyph Red / Cyan
Posted: 2012-07-02T10:43:15-07:00
by MGSteve
Hi Guys,
I'm adding support for MPO files to my gallery scripts and I've run into a bit of a problem.
I've got the 2 images out of the MPO files via exiftool (MPO support in IM is for another thread), but I've run into the problem trying to combine them into a red/cyan anaglyph.
The -stereo parameter of composite outputs red / green for the merged images, but I need red / cyan as these are more common (in my experience anyway).
Is there an easy way to output red / cyan rather than red / green?
TIA
Steve.
Re: anaglyph Red / Cyan
Posted: 2012-07-02T11:13:07-07:00
by fmw42
The only way I know might be to take the green image and convert to grayscale. Then use -fill cyan -colorize, or +level-colors black,cyan (or cyan,white) or blend the grayscale image with cyan to convert to cyan.
Alternately, and perhaps easier, you could try -modulate 100,100,huerotate on your green image to rotate the hue until it gets to cyan.
see
http://www.imagemagick.org/Usage/color_mods/#modulate
http://www.imagemagick.org/Usage/color_ ... vel-colors
http://www.imagemagick.org/Usage/color_mods/#colorize
Re: anaglyph Red / Cyan
Posted: 2012-07-02T14:47:14-07:00
by MGSteve
Just to be clear, the two images I have are full colour, I just pass them to composite to convert to the red & green (although I want it to be cyan) composite anaglyph. I don't have a green image at all.
Re: anaglyph Red / Cyan
Posted: 2012-07-02T15:23:35-07:00
by fmw42
according to -stereo
The left side of the stereo pair is saved as the red channel of the output image. The right side is saved as the green channel. Red-green stereo glasses are required to properly view the stereo image.
So you have a 3 channel resulting image. A red channel with the left, a green channel with the right and probably black for the blue. You can
replace the blue channel with a copy of the green channel. Thus you get the right side having cyan.
try
convert image -stereo +X+Y -separate \
+delete -clone 1 -combine stereo_cyan_image
Re: anaglyph Red / Cyan
Posted: 2012-07-02T15:29:08-07:00
by MGSteve
But in doing that won't you loose the info from the blue channel anyway?
i.e. the Cyan side is supposed to be made up of the Blue & Green channels of the source Right side image, with the red image being made up of the red channel from the source left image.
I don't know why IM chose Red & Green as the colours anyway, Red & Cyan is far more commonly used.
Re: anaglyph Red / Cyan
Posted: 2012-07-02T15:40:45-07:00
by fmw42
MGSteve wrote:But in doing that won't you loose the info from the blue channel anyway?
i.e. the Cyan side is supposed to be made up of the Blue & Green channels of the source Right side image, with the red image being made up of the red channel from the source left image.
.
My understanding, though untested, is that the blue channel after -stereo will be black. So no information will be lost by replacing black in the blue channel with the same information in the green channel.
Red and green or red and blue were the very old ways. I suppose IM has not kept up or given any option to use more current approaches. But it is easy in IM to swap channels. So you can set the colors the way you want.
Re: anaglyph Red / Cyan
Posted: 2012-07-02T15:45:16-07:00
by fmw42
CORRECTION. IM is using two separate input image to create one composite image. I thought it was a convert command.
composite two images to create a stereo anaglyph. [composite]
The left side of the stereo pair is saved as the red channel of the output image. The right side is saved as the green channel. Red-green stereo glasses are required to properly view the stereo image.
I believe from a little testing that the documentation is wrong. The results are red-cyan.
Note the following does not work.
convert logo: -colorspace gray logog.png
convert logog.png -negate logogn.png
composite -stereo +10 logog.png logogn.png tmp.png
There is no shift.
So it seems to be a bug. see
viewtopic.php?f=3&t=21348
but this works and shows that the result is red-cyan.
composite -stereo +10+0 logog.png logogn.png tmp.png
Re: anaglyph Red / Cyan
Posted: 2012-07-03T00:22:29-07:00
by MGSteve
oh my god.
I've just lost about 6 hours of my life trying to find something that generated red/cyan anaglyphs on linux that I won't get back because the documentation was wrong, thanks whoever wrote that.
Thanks fmw42 for your help too. I did try the composite command, but as my pics were taken with a 3D camera, I didn't need an offset, so didn't give one - which composite complains about, but only by saying 'invalid parameter'.
Perhaps if no parameter (i.e. offset) is supplied it should just default to 0.
Re: anaglyph Red / Cyan
Posted: 2012-07-03T10:28:17-07:00
by fmw42
MGSteve wrote:oh my god.
I've just lost about 6 hours of my life trying to find something that generated red/cyan anaglyphs on linux that I won't get back because the documentation was wrong, thanks whoever wrote that.
Thanks fmw42 for your help too. I did try the composite command, but as my pics were taken with a 3D camera, I didn't need an offset, so didn't give one - which composite complains about, but only by saying 'invalid parameter'.
Perhaps if no parameter (i.e. offset) is supplied it should just default to 0.
Use +0+0 or in the IM 6.7.8.1 beta it should now accept +0 or just 0. Some argument must be provided if only 0, according to the docs, only the second argument is optional.
Just curious, but are the glasses you have red-green or red-cyan. The docs still say red-green for the glasses, but the rest has been changed to say that the output will be red-green-green for r,g,b so that it is red-cyan looking.