Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
...but now I want to create green-magenta anaglyphs. Specifically I want to combine the green color channel from the left-eye image, with the red and blue channels from the right-eye image, to create a full color green-magenta stereo 3D anaglyph. Oh, and I would prefer to do it with a single ImageMagick command, because I need to process tens of thousands of images (video frames), and I am worried about disk space and the tedium of cleaning up intermediate files.
Can anyone suggest a one-liner for this process? If not, how about process with a minimum of intermediate files?
Try this. I am not sure if the roll should be positive or negative, but you can try each. I have assumed that your images are color. If they are grayscale already, then the -colorspace gray is not needed
convert \( right -colorspace gray -roll +5+0 \) \( left -colorspace gray \) \( right -colorspace gray -roll +5+0 \) -combine result
Thank you very much fmw42; this is definitely a step in the right direction. However it's not yet exactly what I need.
First, for my purposes, the "roll" statements are unnecessary; my left-eye and right-eye views are already correctly aligned and require no additional depth adjustment. But it's great that you included them there, for others who might read this thread and who have different needs.
More importantly, your recommended command line converts each image to grayscale, then converts those intensities to the output color channels. Believe me, I understand why you would recommend that approach. But I was not kidding when I said I want to extract the green channel from the left image, and the red and blue channels from the right image, and then combine those channels into the synthetic image. There is a big difference between 1) extracting the green channel from an image, and 2) converting an image to grayscale and coloring the result green. I wish to do the former, i.e. extracting three out of the six actual original color channels, to create a so-called "full color" anaglyph.
Is there an alternate command line like this that would truly yield the distinct color channels from each image?
convert \(right -set colorspace RGB -fx R \) \(left -set colorspace RGB -fx G \) \(right -set colorspace RGB -fx B \) -combine result
For some reason I needed to add the "-set colorspace RGB" stanzas, otherwise the output image would be subject to an unwanted dramatically darkening gamma adjustment.
convert \( right -set colorspace RGB -channel r -separate +channel \) \( left -set colorspace RGB -channel g -separate +channel \) \( right -set colorspace RGB -channel b -separate +channel \) -combine result
You are likely on a version of IM that used linear channels. Thus you need to use -set colorspace RGB to "trick" IM into thinking the channels are already linear so that it does not do the non-linear (sRGB) to linear (RGB) conversion and leaves the channels as sRGB. See the link I put above.
It is always a good idea when asking questions on the forum to report the IM version and platform. Answers can them be more correct as they may depend on the version of IM using and platform.
It may be faster to read the input images only once and use clones.
convert left right \( -clone 1 -set colorspace RGB -channel r -separate +channel \) \( -clone 0 -set colorspace RGB -channel g -separate +channel \) \( -clone 1 -set colorspace RGB -channel b -separate +channel \) -delete 0,1 -combine result
convert \( right -set colorspace RGB -channel r -separate +channel \) \( left -set colorspace RGB -channel g -separate +channel \) \( right -set colorspace RGB -channel b -separate +channel \) -combine result
Thanks. That does seem faster than my -fx version.
It is always a good idea when asking questions on the forum to report the IM version and platform. Answers can them be more correct as they may depend on the version of IM using and platform.
Too little too late, but here is my version information anyway (on 64-bit Windows 7):