Creating half-color anaglyph?

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?".
olegk
Posts: 37
Joined: 2013-08-16T11:31:10-07:00
Authentication code: 6789

Creating half-color anaglyph?

Post by olegk »

Is is possible to convert a full-color anaglyph into half-color anaglyph using only imagemagick?
The meaning of the conversion is roughly explained by the following screenshot of Imagen application here:
http://www.dpreview.com/forums/post/52281015
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Creating half-color anaglyph?

Post by fmw42 »

Upload a pair of full anaglyph images and the properly processed half anaglyph image to some place like dropbox.com (public folder) and put links here.

I think it can be done, but would need to verify. I am not quite sure what they are doing in that link.
olegk
Posts: 37
Joined: 2013-08-16T11:31:10-07:00
Authentication code: 6789

Re: Creating half-color anaglyph?

Post by olegk »

Thanks, you always come to rescue :)!
I uploaded three pairs here:
http://www.lazyconv.com/galleries/DEMO/HCA/
The half-color versions have _HCA name suffixes.

The idea of half-color anaglyph is to reduce eye pain by desaturating problematic colors, mostly red.

Regards,
Oleg.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Creating half-color anaglyph?

Post by fmw42 »

olegk wrote:Thanks, you always come to rescue :)!
I uploaded three pairs here:
http://www.lazyconv.com/galleries/DEMO/HCA/
The half-color versions have _HCA name suffixes.

The idea of half-color anaglyph is to reduce eye pain by desaturating problematic colors, mostly red.

Regards,
Oleg.

Are you sure these images are even anaglyph? I see no color offsets in them which is indicative of parallax in anaglyph images. If these are truly anaglyph, then do you also have the original left right pairs?

The link you have above is to create a half anaglyph from the original pair of left/right images, not from a full color anaglyph, as best as I can tell.
olegk
Posts: 37
Joined: 2013-08-16T11:31:10-07:00
Authentication code: 6789

Re: Creating half-color anaglyph?

Post by olegk »

These images are anaglyphs obtained with a DIY variation of QDOS lens. They show less depth, but have a bonus of being suitable for both 2d and 3d viewing. And I did convert them to half-color using that (terribly misbehaving) Imagen application.
Had to revert to Imagen because the more popular Stereophotomaker indeed cannot use full-color anaglyph as the input for such conversion.

Regards,
Oleg.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Creating half-color anaglyph?

Post by fmw42 »

That screen seems to imply that you are starting with a left and right image pair. Is there a different screen when starting with the full anaglyph image rather than the left and right images?

Do you have the original left and right images? If so, please provide the pair for one of the examples sets of anaglyphs.
olegk
Posts: 37
Joined: 2013-08-16T11:31:10-07:00
Authentication code: 6789

Re: Creating half-color anaglyph?

Post by olegk »

Here is a screenshot from my computer while processing an anaglyph original:
http://www.lazyconv.com/galleries/DEMO/ ... 3D_HCA.jpg
A single filename in the top-left corner proves the original is not a stereopair. Besides, I've got no reason to confuse you :).
Of course, one can separate the original into left- and right images if needed using imagemagick.

Thanks,
Oleg.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Creating half-color anaglyph?

Post by fmw42 »

It is not a question of confusion. I was wondering if you could provide the original pair so I could try to recreate the full anaglyph to be sure I understand how yours was created. Then I can be sure that I am processing from the full to half with the right equations.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Creating half-color anaglyph?

Post by fmw42 »

According to this reference: http://www.3dtv.at/knowhow/anaglyphcomparison_en.aspx and my analysis of it, you cannot convert full color anaglyph to half color anaglyph without having the original left color image.

The full color anaglyph channels are created from the left image (1) and right image (2), by combining channels as follows
full color (r,g,b) = R1, G2, B2

Half color (r,g,b) = (0.299*R1+0.587*G1+0.114*B1), G2, B2

Since the full color anaglyph channels are missing G1 and B1, there is no way to get that information without the left original image.

So if you want either full or half color anaglyph images, you need to start with the original left and right side images.
olegk
Posts: 37
Joined: 2013-08-16T11:31:10-07:00
Authentication code: 6789

Re: Creating half-color anaglyph?

Post by olegk »

Thanks for your effort, Fred.
Still it's interesting to understand what the hack that Imagen3D is doing when presented with full-color anaglyph as the input.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Creating half-color anaglyph?

Post by fmw42 »

I do not know what they do, but here is one concept. I use my histmatch script to match the histogram of the (left) red channel to the (right) blue and green channels to simulate the left green and blue channels. Then combine the left red with the simulated left green and blue and convert to grayscale. Then combine the new left grayscale as the red channel with the right green and blue channels to make the half anaglyph. Here is the code. You need Linux/Mac OS or Windows w/Cygwin to run my histmatch script.

Code: Select all

convert DSC03983_48-52_s050g092.JPG -separate tmp_%d.png
histmatch -c gray tmp_1.png tmp_0.png tmp_green.png
histmatch -c gray tmp_2.png tmp_0.png tmp_blue.png
convert tmp_0.png tmp_green.png tmp_blue.png -poly "0.298839,1 0.586811,1 0.114350,1" tmp_left.png
convert tmp_left.png tmp_1.png tmp_2.png -set colorspace sRGB -combine \
-colorspace sRGB DSC03983_48-52_s050g092_half.JPG
rm -f tmp_0.png tmp_1.png tmp_2.png tmp_green.png tmp_blue.png tmp_left.png
http://www.fmwconcepts.com/misc_tests/a ... 2_half.JPG

P.S. Is it possible that all they did was to desaturate the full color anaglyph to make the half color anaglyph. In IM use -modulate 100,X,100 where X = 0 is full desaturated and X = 100 is no desaturation.

-modulate 100,50,100
http://www.fmwconcepts.com/misc_tests/a ... esat50.JPG


-modulate 100,35,100
http://www.fmwconcepts.com/misc_tests/a ... esat35.JPG
olegk
Posts: 37
Joined: 2013-08-16T11:31:10-07:00
Authentication code: 6789

Re: Creating half-color anaglyph?

Post by olegk »

Well, neither of your suggestions matches their result, and their's makes more sense. Maybe they "reduced" only the red channel? If you separate the image into the three colors, what is the appropriate Imagemagick command to "reduce" each channel individually? I already learned that one cannot "desaturate" one prime color :).

Thanks,
Oleg.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Creating half-color anaglyph?

Post by fmw42 »

Desaturate the color image and then select the channel you want.


Or try adding two other black images to fill in the one channel to a full rgb image. Then -modulate 100,X,100. Then extract the original channel. For example:

Code: Select all

convert rose: -channel r -separate -write rose_red.png \
\( -clone 0 -fill black -colorize 100 \) +duplicate -combine \
-modulate 100,50,100 -channel r -separate rose_red_demod.png
Now compare rose_red.png and rose_red_demod.png


I am still curious if you have an original pair of stereo images (esp if for the image I used above). If so, would you post it so I can play with it.

P.S. Have you tried creating a pseudo-anaglyph from a single image using IM -stereo (http://www.imagemagick.org/script/comma ... php#stereo). Then uploading just that anaglyph to your other software and see what kind of half-color result is created. Can you try that and post the two images here.
olegk
Posts: 37
Joined: 2013-08-16T11:31:10-07:00
Authentication code: 6789

Re: Creating half-color anaglyph?

Post by olegk »

Thanks, Fred.
Maybe I wasn't clear enough. I'm taking immediate 3d color anaglyphs in a single shot by a single lens. This method was patented in 1973, and a lens named QDOS has been produced a while ago. You just glue a color filter to the back of the lens to emulate it - one half covered by red, another - by cyan. The resulting image needs some massage, and I'm gradually improving the relevant scripting. You can see some early results here:
http://www.lazyconv.com/galleries/Root/ ... index.html
It's strongly recommended to see full-size versions.

In most cases full-color images are fine, but red flowers do require half-color.
I'll try your suggestions when I get access to my Windows computer.

Regards,
Oleg.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Creating half-color anaglyph?

Post by fmw42 »

OK. Thanks. So you really have no starting stereo pair.

Try creating this command. Then load the image into your tool and convert to half anaglyph and post the result. I may be able to figure something out from the before and after profiles.


Code: Select all

composite \( -size 512x512 gradient: -rotate 90 \) \( -size 512x512 gradient: -rotate 90 \) -stereo +20+0 grad_stereo.png
Post Reply