[GRASS-SVN] r56712 - grass-addons/grass6/display/d.anaglyph
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Jun 15 02:26:33 PDT 2013
Author: hamish
Date: 2013-06-15 02:26:32 -0700 (Sat, 15 Jun 2013)
New Revision: 56712
Modified:
grass-addons/grass6/display/d.anaglyph/d.anaglyph
grass-addons/grass6/display/d.anaglyph/description.html
Log:
set style by a drop-down option instead of combination of flags.
add a rescue flag in case NVIZ decides to spontaneously flip one of the images.
make cross-eyed flag flip the images left-for-right.
increase freeview guide's margin width and improve wording.
various man page improvements.
Modified: grass-addons/grass6/display/d.anaglyph/d.anaglyph
===================================================================
--- grass-addons/grass6/display/d.anaglyph/d.anaglyph 2013-06-15 07:04:35 UTC (rev 56711)
+++ grass-addons/grass6/display/d.anaglyph/d.anaglyph 2013-06-15 09:26:32 UTC (rev 56712)
@@ -27,6 +27,7 @@
# to see the 3D effect, so we use some inefficient rotations to get
# around that.~~ --update-- That's wrong, it's the *minor axis* which
# does not preserve the map rotation.
+# If it still goes wrong use the -r flag to recover.
#%Module
#% description: Creates a sterographic 3D image suitable for viewing with red/cyan glasses or by simply crossing your eyes.
@@ -49,12 +50,22 @@
#% gisprompt: new,file,file
#%End
#%Option
+#% key: style
+#% type: string
+#% required: no
+#% description: Type of stereo image to create
+#% options: anaglyph,stereogram,freeview
+#% descriptions: anaglyph;For viewing with red/cyan glasses;stereogram;For viewing with a stereograph mirror viewer;freeview;For viewing with the unaided eye
+#% answer: anaglyph
+#%End
+#%Option
#% key: size
#% type: integer
#% required: no
#% multiple: no
#% key_desc: width,height
-#% description: Width and height of output image
+#% label: Width and height of output image
+#% description: When creating bifurcated sterogram pairs this option sets the size of each pane.
#% answer: 640,480
#%End
#%Option
@@ -72,7 +83,7 @@
#% required: no
#% multiple: no
#% key_desc: value
-#% description: Z-exaggeration
+#% description: Vertical exaggeration
#% answer: 2.0
#%End
#%Option
@@ -90,7 +101,7 @@
#% required: no
#% multiple: yes
#% key_desc: name
-#% description: Name of point vector overlay map
+#% description: Name of points vector overlay map
#% gisprompt: old,vector,vector
#% guisection: Vector overlay
#%End
@@ -101,7 +112,7 @@
#% multiple: yes
#% options: 1-10000
#% key_desc: value
-#% description: Icon size (map units)
+#% description: Vector points icon size (map units)
#% answer: 100
#% guisection: Vector overlay
#%End
@@ -129,25 +140,24 @@
#%End
#%Flag
#% key: f
-#% description: Flatten terrain
+#% description: Flatten terrain (anaglyph mode only)
#%End
#%Flag
#% key: e
-#% description: Equalize contrast
+#% description: Equalize contrast (anaglyph mode only)
#%End
#%Flag
-#% key: s
-#% label: Create a bifurcated sterogram pair instead of a blue/cyan anaglyph
-#% description: In this case the size option sets the size of each pane.
-#%End
-#%Flag
#% key: c
#% description: Cross-eyed mode for bifurcated sterogram pair
#%End
#%Flag
#% key: g
-#% description: Create fiducial marks for regular stereograms or a viewing guide for cross-eyed stereograms
+#% description: Create fiducial marks for regular stereograms or a viewing guide for free-view stereograms
#%End
+#%Flag
+#% key: r
+#% description: In case of spontaneous NVIZ flipping, rotate one of the frames back into position (debug)
+#%End
if [ -z "$GISBASE" ] ; then
@@ -282,6 +292,7 @@
#### dynamic viewpoint height calculations
+# FIXME: figure out if it is map unit extent or number of cells which controls the flipping
eval `g.region -ge`
# various scales of the average map extent to use for the viewing height
avg_extent=`echo "$ns_extent $ew_extent" | awk '{print ($1 + $2)/2.0}'`
@@ -297,7 +308,7 @@
extent_frac=`echo "$avg_extentN" | awk '{print 0.005 * $1}'`
-if [ "$GIS_FLAG_S" -ne 1 ] ; then
+if [ "$GIS_OPT_STYLE" = "anaglyph" ] ; then
g.message "Preparing map ..."
r.mapcalc "$TEMP_IMG = $INMAP"
r.colors $EFLAG "$TEMP_IMG" color=grey --quiet
@@ -308,7 +319,7 @@
## spearfish example at z-ex=4 + "-s" flips?
-if [ $GIS_FLAG_F -eq 1 ] ; then
+if [ "$GIS_FLAG_F" -eq 1 ] ; then
#### flat image ####
if [ -n "$GIS_OPT_VIEWING_HEIGHT" ] ; then
height="$GIS_OPT_VIEWING_HEIGHT"
@@ -325,6 +336,14 @@
TWIST=90
fi
+ if [ "$GIS_FLAG_R" -eq 1 ] ; then
+ if [ "$TWIST" -eq 90 ] ; then
+ TWIST=180
+ else
+ TWIST=90
+ fi
+ fi
+
RENDER_OPTS="resolution_fine=1 perspective=15 twist=$TWIST \
position=0.5,0.5 bgcolor=black $VLINES $VPOINTS $DRAPE"
@@ -353,7 +372,7 @@
g.region save="tmp_anaglyph.$$"
WIND_OVERRIDE="tmp_anaglyph.$$"
export WIND_OVERRIDE
- if [ "$GIS_FLAG_S" -ne 1 ] ; then
+ if [ "$GIS_OPT_STYLE" = "anaglyph" ] ; then
g.region rast="$TEMP_IMG"
fi
@@ -383,6 +402,15 @@
TWIST_L=90
fi
+ # if it fails let the user control the rotation
+ if [ "$GIS_FLAG_R" -eq 1 ] ; then
+ if [ "$TWIST_L" -eq 90 ] ; then
+ TWIST_L=-90
+ else
+ TWIST_L=90
+ fi
+ fi
+
SPREAD_L=`echo "$SPREAD" | awk '{print 0.5 - $1}'`
SPREAD_R=`echo "$SPREAD" | awk '{print 0.5 + $1}'`
@@ -446,7 +474,7 @@
}
-if [ "$GIS_FLAG_S" -ne 1 ] ; then
+if [ "$GIS_OPT_STYLE" = "anaglyph" ] ; then
# split into R,G,B components
g.message "Creating anaglyph ..."
ppmtorgb3 "$BASENM.left.ppm" &
@@ -462,7 +490,7 @@
HEIGHT=`echo "$SIZE" | cut -f2 -d,`
create_pbm 5 "$HEIGHT" white "$TEMPFILE.gutter.pbm"
- if [ "$GIS_FLAG_C" -ne 1 ] ; then
+ if [ "$GIS_OPT_STYLE" = "stereogram" ] ; then
if [ "$GIS_FLAG_G" -eq 1 ] ; then
# fiducial mark overlay
@@ -535,21 +563,32 @@
wait
fi
- pnmcat -leftright "$BASENM.right.ppm" "$TEMPFILE.gutter.pbm" \
- "$BASENM.left.ppm" > "$BASENM.anaglyph.ppm"
+ if [ "$GIS_FLAG_C" -ne 1 ] ; then
+ pnmcat -leftright "$BASENM.right.ppm" "$TEMPFILE.gutter.pbm" \
+ "$BASENM.left.ppm" > "$BASENM.anaglyph.ppm"
+ else
+ pnmcat -leftright "$BASENM.left.ppm" "$TEMPFILE.gutter.pbm" \
+ "$BASENM.right.ppm" > "$BASENM.anaglyph.ppm"
+ fi
check_ret
else
-
+ # create a freeview stereogram
if [ "$GIS_FLAG_G" -ne 1 ] ; then
- pnmcat -leftright "$BASENM.left.ppm" "$TEMPFILE.gutter.pbm" \
- "$BASENM.right.ppm" > "$BASENM.anaglyph.ppm"
+ # no guide, just the two images
+ if [ "$GIS_FLAG_C" -ne 1 ] ; then
+ pnmcat -leftright "$BASENM.left.ppm" "$TEMPFILE.gutter.pbm" \
+ "$BASENM.right.ppm" > "$BASENM.anaglyph.ppm"
+ else
+ pnmcat -leftright "$BASENM.right.ppm" "$TEMPFILE.gutter.pbm" \
+ "$BASENM.left.ppm" > "$BASENM.anaglyph.ppm"
+ fi
check_ret
else
-
- # thanks (public domain)
- # http://upload.wikimedia.org/wikipedia/commons/1/10/Stereo_Pair%2C_Lake_Palanskoye_Landslide%2C_Kamchatka_Peninsula%2C_Russia.jpg
- SIDE_WIDTH=50
+ # nest in a viewing guide
+ # thanks to: (public domain)
+ # http://upload.wikimedia.org/wikipedia/commons/1/10/Stereo_Pair%2C_Lake_Palanskoye_Landslide%2C_Kamchatka_Peninsula%2C_Russia.jpg
+ SIDE_WIDTH=60
GUTTER_WIDTH=5
WIDTH=`echo "$SIZE" | cut -f1 -d,`
WIDTH2=`expr "$WIDTH" "*" 2 + $SIDE_WIDTH + $SIDE_WIDTH + $GUTTER_WIDTH`
@@ -579,7 +618,7 @@
d.font "$VALID_FONT"
fi
cat << EOF | d.text at=50,67 align=cc size=25 color=white linespacing=2
-To view stereo pair, cross eyes slightly until a third
+To view the stereo pair, cross your eyes slightly until a third
white dot appears between the two. New center image is 3D!
EOF
d.mon stop=cairo --quiet
@@ -598,9 +637,15 @@
> "$BASENM.dotleft.ppm"
check_ret
- pnmcat -leftright "$TEMPFILE.side.pbm" "$BASENM.dotleft.ppm" \
- "$TEMPFILE.gutter.pbm" "$BASENM.dotright.ppm" "$TEMPFILE.side.pbm" \
- > "$BASENM.upper.ppm"
+ if [ "$GIS_FLAG_C" -ne 1 ] ; then
+ pnmcat -leftright "$TEMPFILE.side.pbm" "$BASENM.dotleft.ppm" \
+ "$TEMPFILE.gutter.pbm" "$BASENM.dotright.ppm" "$TEMPFILE.side.pbm" \
+ > "$BASENM.upper.ppm"
+ else
+ pnmcat -leftright "$TEMPFILE.side.pbm" "$BASENM.dotright.ppm" \
+ "$TEMPFILE.gutter.pbm" "$BASENM.dotleft.ppm" "$TEMPFILE.side.pbm" \
+ > "$BASENM.upper.ppm"
+ fi
check_ret
pnmcat -topbottom "$BASENM.upper.ppm" "$TEMPFILE.text.ppm" \
Modified: grass-addons/grass6/display/d.anaglyph/description.html
===================================================================
--- grass-addons/grass6/display/d.anaglyph/description.html 2013-06-15 07:04:35 UTC (rev 56711)
+++ grass-addons/grass6/display/d.anaglyph/description.html 2013-06-15 09:26:32 UTC (rev 56712)
@@ -1,15 +1,15 @@
<h2>DESCRIPTION</h2>
<em>d.anaglyph</em> creates a sterographic 3D image suitable for viewing
-either with red/cyan glasses, a stereograph viewer, or by simply crossing
-your eyes. Vector line and point maps may be draped over the raster surface.
+either with red/cyan glasses, a stereograph viewer, or unaided by simply
+focusing into the distance or crossing your eyes. Vector line and point
+maps may be draped over the raster surface.
<p>
Stereograms (two images side by side) will be in full color. Anaglyphs
(needing red/cyan glasses) will be in greyscale, but some colors like
-yellow can be used. This module allows creation of stereograms either
-in straight mode (requiring a stereoscopic viewer), or cross-eyed, which
-you can do "free-view" without any special tools.
+yellow can be used. This module allows creation of stereograms either in
+parallel or cross-eyed mode.
<h2>NOTES</h2>
@@ -18,40 +18,65 @@
The output file will be a PNG image.
<p>
-For "free-view" cross-eyed stereograms the <b>-g</b> flag is provided to
-help guide your eyes, by adding instructions and two white dots to focus on.
-It will be hard to focus the dots if they are more than the width of your
-eyes appart, in this case it is recommended to not set the image <b>size</b>
-of each pane any greater than about 200 pixels, so the two panes look like
-bookmarks. The narrower the image the easier it will be to focus on, but
-the less you will be able to see.
+The cross-eyed flag simply flips the image pair left-for-right. If the
+mountains look like valleys to you, or considerable eye strain is needed
+to obtain a 3D effect, try using this flag. 3D image cognition is not
+universal among individuals, some trial and error may be needed to create
+an image that works well for you.
-<p>
-For "regular" stereograms to be viewed with a stereograph viewer, the
-<b>-g</b> flag will overlay middle-of-image fiducial marks for easier
-alignment.
+<h3>Anaglyphs</h3>
+
<center>
-<img src="spearfish_stereogram_fiducial.jpg" align="center">
+<img src="spearfish_anaglyph.png" width="400">
</center>
<p>
If draping a <b>color_overlay</b> raster map over the top of a DEM in
anaglyph mode, it works best to first change the color map of the overlay
-raster to greyscale or sepia with the <em>r.color</em> module (perhaps with
-the <b>-e</b> flag), to avoid any red/cyan in the overlay's color table from
-confusing the 3D effect.
+raster to greyscale or sepia with the <em>r.color</em> module (perhaps
+with the <b>-e</b> flag), to prevent any red/cyan in the overlay's color
+table from confusing the 3D effect.
<p>
-The flatten terrain and equalize contrast flags only operate in anaglyph mode,
-and the equalize contrast flags only applies to the base DEM, and will not
-have an effect if a <b>color_overlay</b> raster map is used.
+The flatten terrain and equalize contrast flags only operate in anaglyph
+mode. The equalize contrast flag only applies to the base DEM and
+will not have an effect if a <b>color_overlay</b> raster map is used.
+
+<h3>Stereograms</h3>
+
<center>
-<img src="spearfish_anaglyph.png">
+<img src="spearfish_stereogram_fiducial.jpg" align="center">
</center>
+<p>
+For standard stereograms to be viewed with a stereoscopic viewer the
+<b>-g</b> flag will overlay middle-of-image fiducial marks for easier
+alignment.
+<p>
+For "free-view" stereograms, the <b>-g</b> flag helps guide your eyes by
+adding instructions and two white dots to focus on. In parallel viewing
+mode (the default) it will be hard to focus the dots if they are more
+than the width of your eyes appart, in this case it is recommended to not
+set the image <b>size</b> of each pane any greater than about 180 or 200
+pixels, so the two panes look like bookmarks. The narrower the image the
+easier it will be to focus on, but the less you will be able to see.
+<br><br>
+<center>
+<img src="spearfish_stereogram_guide.jpg" align="center">
+</center>
+
+<p>
+Cross-eyed free-viewing allows for observing full-width images, but it
+may take a bit more practice to master the technique: hold your
+finger up mid-way between your nose and the image in front of you, and
+while focusing on it try to get the two images in the background to
+overlap. When they do try to lock in on the central image in the
+background instead of your finger without altering your eyes' focus.
+
+
<h2>EXAMPLES</h2>
North Carolina dataset anaglyph:
@@ -70,24 +95,28 @@
</pre></div>
-Spearfish dataset cross-eyed stereogram:
+Spearfish dataset free-view stereogram:
<div class="code"><pre>
g.region rast=elevation.10m
r.colors -e elevation.10m color=haxby
-d.anaglyph -scg input=elevation.10m output=spearfish_stereogram.png \
- size=185,500 viewing_height=27000
+d.anaglyph -g input=elevation.10m output=spearfish_stereogram.png \
+ style=freeview size=185,500 viewing_height=27000
</pre></div>
-<center>
-<img src="spearfish_stereogram_guide.jpg" align="center">
-</center>
+<h2>TODO and BUGS</h2>
-<h2>TODO</h2>
-
-Fine tuning; needs more viewpoint separation when the z-exaggeration is high.
+Fine tuning; needs more viewpoint separation when the z-exaggeration
+is high.
+<br>
View is currently limited to top-down.
-Sometimes one of the images flips (adjust the region width).
+<br>
+NVIZ ties the viewing height to the vertical exaggeration and
+perspective settings, after changing the <b>z_exag</b> option you
+may find you need to change the <b>viewing_height</b> option as well.
+<br>
+Sometimes one of the images flips (if this happens, try using the
+<b>-r</b> flag or adjusting the region width).
<h2>SEE ALSO</h2>
@@ -96,8 +125,8 @@
<a href="m.nviz.image.html">m.nviz.image</a>,
<a href="nviz.html">NVIZ</a><br>
</em>
-The <a href="http://grasswiki.osgeo.org/wiki/Stereo_anaglyphs">Stereo anaglyphs</a>
-page on the GRASS Wiki
+The <a href="http://grasswiki.osgeo.org/wiki/Stereo_anaglyphs">Stereo
+ anaglyphs</a> page on the GRASS Wiki
<h2>AUTHOR</h2>
More information about the grass-commit
mailing list