Gimp instructions convert to Imagemagick - anaglyphs
Posted: 2008-11-23T16:13:39-07:00
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
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