How to create an anaglyph (stereo image) with modified depth

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?".
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to create an anaglyph (stereo image) with modified depth

Post by anthony »

lynx_abraxas wrote:One grey image for red and another for cyan/bg (because our "glasses" are red, cyan). I got to that command from the line in the channels examples (http://www.imagemagick.org/Usage/channels/#channels):
As such, even if you use a "-channel BR" setting, "-combine" will expect two images, first the red then the blue. The green and alpha values will be set from the current "-background" setting values.
At the start of the channels section I say...
Before going any further I suggest you read about how IM actually saves images in memory by reading Image Storage Color System.
I suggest you do this as it would explain that images are stored either as RGB or CMY or CMYK (or some other data representation. You can not have a both a RED and a CYAN channel in the same image memory representation. Such as representation would be incomplete anyway.

It goes on to explain that channel 'Cyan' or 'C' is actually a alias for the same data as 'Red' or 'R' channel. The meaning of that data depends on As such -channels RC is equivalent to -channels RR or just the Red channel. Thus only one channel, the red channel, will be extracted!!!!!

However CYAN is really just BOTH the combined GREEN and BLUE Channels, in the RGB colorspace. So all that is needed is to shift the red channel one way, and the blue and green channel the other way, together.

Now your input image is grayscale. so why not do this

Code: Select all

  read image add pixels on right
  ( clone image  roll image right )
  ( clone last image )
  combine the three images as RGB
OR

Code: Select all

convert gray_image.png \
     -background black -gravity east -splice 5x0+0+0 \
     \( +clone -roll +5+0 \) \
     \( +clone \) \
     -combine anaglyph.png
and your have your base anaglyph for red-cyan glasses.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to create an anaglyph (stereo image) with modified depth

Post by fmw42 »

anthony wrote:
lynx_abraxas wrote:One grey image for red and another for cyan/bg (because our "glasses" are red, cyan). I got to that command from the line in the channels examples (http://www.imagemagick.org/Usage/channels/#channels):
As such, even if you use a "-channel BR" setting, "-combine" will expect two images, first the red then the blue. The green and alpha values will be set from the current "-background" setting values.
At the start of the channels section I say...
Before going any further I suggest you read about how IM actually saves images in memory by reading Image Storage Color System.
I suggest you do this as it would explain that images are stored either as RGB or CMY or CMYK (or some other data representation. You can not have a both a RED and a CYAN channel in the same image memory representation. Such as representation would be incomplete anyway.

It goes on to explain that channel 'Cyan' or 'C' is actually a alias for the same data as 'Red' or 'R' channel. The meaning of that data depends on As such -channels RC is equivalent to -channels RR or just the Red channel. Thus only one channel, the red channel, will be extracted!!!!!

However CYAN is really just BOTH the combined GREEN and BLUE Channels, in the RGB colorspace. So all that is needed is to shift the red channel one way, and the blue and green channel the other way, together.

Now your input image is grayscale. so why not do this

Code: Select all

  read image add pixels on right
  ( clone image  roll image right )
  ( clone last image )
  combine the three images as RGB
OR

Code: Select all

convert gray_image.png \
     -background black -gravity east -splice 5x0+0+0 \
     \( +clone -roll +5+0 \) \
     \( +clone \) \
     -combine anaglyph.png
and your have your base anaglyph for red-cyan glasses.

Well, one more point that this seems to me to be somewhat a futile exercise. You may get a stereo effect when viewing, but will it have any meaning without two different images?
Post Reply