I have been trying to follow the instructions here:
http://www.puppetkites.net/blog/archives/94
So far I have a working anaglyph but I wish to do some more optimizations.
#!/bin/bash
inputfile=$1
mkdir tmp 2>/dev/null
echo "Processing $inputfile......."
outputfile=$(echo $inputfile | sed 's/[.].*$//')
#1. Create the left and right images
convert $inputfile -set option:distort:viewport -24-0 -virtual-pixel tile -distort SRT 0 +repage $outputfile-right.png
convert $inputfile -set option:distort:viewport +24-0 -virtual-pixel tile -distort SRT 0 +repage $outputfile-left.png
#2. Left image, need to crop right side, right image crop left side
convert $outputfile-left.png -gravity east -chop 24x0 $outputfile-leftA.png
convert $outputfile-right.png -chop 24x0 $outputfile-rightA.png
#3. Resize to 640x480
convert $outputfile-leftA.png -resize 640x480! $outputfile-leftAA.png
convert $outputfile-rightA.png -resize 640x480! $outputfile-rightAA.png
#4. Apply the Hue Saturation filter equally to the left and right perspectives (Tools > Color Tools > Hue-Saturation). An example for a color tweak might be Red Hue +36 and Lightness -27:
#------------------> NOT WORKING, need to apply just to RED. How?
#convert $outputfile-leftA.png -modulate 0,-27,36 $outputfile-leftAA.png
#convert $outputfile-rightA.png -modulate 0,-27,36 $outputfile-rightAA.png
#5. Apply a Gamma Levels filter to the left perspective (e.g. Tools > Color Tools > Levels) and raise the Gamma output level to about 12 or so
#------------------>I did a visual comparison between gimp's output and imagemagicks and this is my closest approximation. Maybe there is a better way?
convert $outputfile-leftAA.png -level 0%,100%,1.2 $outputfile-leftAAA.png
convert $outputfile-rightAA.png -level 0%,100%,1.0 $outputfile-rightAAA.png
#6. Apply the Channels Mixer filter to the left perspective (Filters > Colors > Channel Mixer). In the Red Output Channel, change the Red amount to 0.0, change the Green amount to 66.6 and the Blue amount to 33.3. You can play with the Green and Blue settings a bit, e.g. some people might prefer G 70.0 and B 30.0:
#Convert the left perspective to Red (Color Tools > Levels and lower the Green and Blue Output Levels to 0)
#-------------------> I am fairly certain this is correct, but please comment.
convert $outputfile-leftAAA.png -channel r -fx '+u.r*0 + u.g*0.66 + u.b*0.33' -channel g -fx '+u.r*0 + u.g*0 + u.b*0' -channel b -fx '+u.r*0 + u.g*0 + u.b*0' $outputfile-red-left-RGB.png
#7. Convert the right perspective to Cyan (Color Tools > Levels and lower the Red Output Level to 0)
convert $outputfile-rightAAA.png -channel R -fx 0 $outputfile-cyan-right-RGB.png
#8. Layer the new Red and Cyan Layers into one frame (Select All > Copy, then Paste), then in the Layers Panel (Dialog > Layers), select the Screen Mode
convert $outputfile-red-left-RGB.png -channel r -separate "(" +channel $outputfile-cyan-right-RGB.png -separate -delete -3 ")" +channel -combine -depth 8 tmp/$outputfile.png
rm $outputfile-*.png
------------------------> I am trying to optimize the anaglyphs according to:
http://www.3dtv.at/Knowhow/AnaglyphComparison_en.aspx
So far I see a big difference just adding step #6 with a reduction in retinal rivalry.
There are probably ways to make the script faster.
I would appreciate any pointers you can give me
Thanks
Chris
Gimp instructions convert to Imagemagick - anaglyphs
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Gimp instructions convert to Imagemagick - anaglyphs
you may want to look at recolor to do the color matrix operation as it is much faster than -fx
http://www.imagemagick.org/Usage/color/#recolor
http://www.imagemagick.org/Usage/color/#recolor
Last edited by fmw42 on 2008-11-23T18:00:51-07:00, edited 1 time in total.
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: Gimp instructions convert to Imagemagick - anaglyphs
You can combine the last four commands into one and remove the unnecessary -fx computations on the green and blue channels.
Pete
Code: Select all
convert $left -channel r -fx '+u.r*0 + u.g*0.66 + u.b*0.33' -gamma 1.2 -separate "(" $right -channel gb -separate ")" -channel rgb -combine anaglyph_opt.png
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
See my message in this topic for a link to a zip of all the files.
Re: Gimp instructions convert to Imagemagick - anaglyphs
Thanks for the replies.
I will try those suggestions. Ultimately, I want to be able to create an anaglyph video using mencoder. I extracted png files from an avi and applied the anaglyph script to the individual pngs, and used mencoder to convert the png files back to avi. I notice that while the anaglyph png have no ghosting, once they are converted into rawvideo avi by mencoder or ffmpeg (which does it upside down), ghosting artifacts are introduced (and this is prior to converting the rawvideo to h264 or mpeg4). Any idea on how to eliminate them? It seems the red color on the avi frames is more pronounced than in the png files and I believe this is causing the ghosting.
Thanks
Chris
I will try those suggestions. Ultimately, I want to be able to create an anaglyph video using mencoder. I extracted png files from an avi and applied the anaglyph script to the individual pngs, and used mencoder to convert the png files back to avi. I notice that while the anaglyph png have no ghosting, once they are converted into rawvideo avi by mencoder or ffmpeg (which does it upside down), ghosting artifacts are introduced (and this is prior to converting the rawvideo to h264 or mpeg4). Any idea on how to eliminate them? It seems the red color on the avi frames is more pronounced than in the png files and I believe this is causing the ghosting.
Thanks
Chris
Re: Gimp instructions convert to Imagemagick - anaglyphs
Thank You el_supremo and fmw42. I followed your suggestions and came up with:
convert $outputfile-leftA.png -channel r -recolor '0 .66 .33 0 0 0 0 0 0' -gamma 1.2 -separate "(" $outputfile-rightA.png -channel gb -separate ")" -channel rgb -combine tmp/$outputfile.png
which does the same thing faster.
Any ideas on how I could do step #4?
Thanks
Chris
convert $outputfile-leftA.png -channel r -recolor '0 .66 .33 0 0 0 0 0 0' -gamma 1.2 -separate "(" $outputfile-rightA.png -channel gb -separate ")" -channel rgb -combine tmp/$outputfile.png
which does the same thing faster.
Any ideas on how I could do step #4?
Thanks
Chris
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Gimp instructions convert to Imagemagick - anaglyphs
To do step 4 in one command you need parenthesis and the -write command
http://www.imagemagick.org/Usage/basics/#parenthesis
http://www.imagemagick.org/Usage/files/#write
Not sure it saves you much though.
http://www.imagemagick.org/Usage/basics/#parenthesis
http://www.imagemagick.org/Usage/files/#write
Not sure it saves you much though.