Skip to content

Commit bbcda18

Browse files
committed
Add anaglyph.
1 parent b13ae31 commit bbcda18

2 files changed

Lines changed: 95 additions & 9 deletions

File tree

documentation/all_docs_ref/all_refs.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ its use requires resorting to the \myreflink{Monolithic} mode.
6161

6262
| | | | | | | | |
6363
|:-----|:----|:----|:----|:----|:----|:----|:----|
64-
| \myreflink{ablines} | \myreflink{append2fig} | \myreflink{blendimg!} | \myreflink{cart2pol} | \myreflink{cart2sph} | \myreflink{colorzones!} | \myreflink{cpt4dcw} | \myreflink{crop} |
65-
| \myreflink{cubeplot} | \myreflink{coastlinesproj} | \myreflink{cubeslice} | \myreflink{date2doy} | \myreflink{delrows!} | \myreflink{doy2date} | \myreflink{findpeaks} | \myreflink{gadm} |
66-
| \myreflink{geocoder} | \myreflink{geodetic2enu} | \myreflink{getbyattrib} | \myreflink{gmtread} | \myreflink{gmtwrite} | \myreflink{graticules} | \myreflink{gridit} | \myreflink{gunique} |
67-
| \myreflink{hampel} | \myreflink{imagesc} | \myreflink{inpolygon} | \myreflink{inwhichpolygon} | \myreflink{image_alpha!} | \myreflink{image_cpt!} | \myreflink{imshow} | \myreflink{ind2rgb} |
68-
| \myreflink{info} | \myreflink{isnodata} | \myreflink{isoutlier} | \myreflink{lazread} | \myreflink{lazwrite} | \myreflink{leepacific} | \myreflink{lelandshade} | \myreflink{linearfitxy} |
69-
| \myreflink{magic} | \myreflink{mat2ds} | \myreflink{mat2grid} | \myreflink{mat2img} | \myreflink{mosaic} | \myreflink{ODE2ds} | \myreflink{orbits} | \myreflink{pca} |
70-
| \myreflink{plotgrid!} | \myreflink{plotyy} | \myreflink{pol2cart} | \myreflink{polygonlevels} | \myreflink{rasterzones!} | \myreflink{regiongeog} | \myreflink{remotegrid} | \myreflink{rescale} |
71-
| \myreflink{slicecube} | \myreflink{sph2cart} | \myreflink{stackgrids} | \myreflink{ter2cart} | \myreflink{theme} | \myreflink{uniqueind} | \myreflink{vecangles} | \myreflink{whereami} |
72-
| \myreflink{worldrectgrid} | \myreflink{worldrectcoast} | \myreflink{worldrectangular} | \myreflink{xyzw2cube} | \myreflink{yeardecimal} | \myreflink{zonal_stats} | | |
64+
| \myreflink{ablines} | \myreflink{anaglyph} | \myreflink{append2fig} | \myreflink{blendimg!} | \myreflink{cart2pol} | \myreflink{cart2sph} | \myreflink{colorzones!} | \myreflink{cpt4dcw} |
65+
| \myreflink{crop} | \myreflink{cubeplot} | \myreflink{coastlinesproj} | \myreflink{cubeslice} | \myreflink{date2doy} | \myreflink{delrows!} | \myreflink{doy2date} | \myreflink{findpeaks} |
66+
| \myreflink{gadm} | \myreflink{geocoder} | \myreflink{geodetic2enu} | \myreflink{getbyattrib} | \myreflink{gmtread} | \myreflink{gmtwrite} | \myreflink{graticules} | \myreflink{gridit} |
67+
| \myreflink{gunique} | \myreflink{hampel} | \myreflink{imagesc} | \myreflink{inpolygon} | \myreflink{inwhichpolygon} | \myreflink{image_alpha!} | \myreflink{image_cpt!} | \myreflink{imshow} |
68+
| \myreflink{ind2rgb} | \myreflink{info} | \myreflink{isnodata} | \myreflink{isoutlier} | \myreflink{lazread} | \myreflink{lazwrite} | \myreflink{leepacific} | \myreflink{lelandshade} |
69+
| \myreflink{linearfitxy} | \myreflink{magic} | \myreflink{mat2ds} | \myreflink{mat2grid} | \myreflink{mat2img} | \myreflink{mosaic} | \myreflink{ODE2ds} | \myreflink{orbits} |
70+
| \myreflink{pca} | \myreflink{plotgrid!} | \myreflink{plotyy} | \myreflink{pol2cart} | \myreflink{polygonlevels} | \myreflink{rasterzones!} | \myreflink{regiongeog} | \myreflink{remotegrid} |
71+
| \myreflink{rescale} | \myreflink{slicecube} | \myreflink{sph2cart} | \myreflink{stackgrids} | \myreflink{ter2cart} | \myreflink{theme} | \myreflink{uniqueind} | \myreflink{vecangles} |
72+
| \myreflink{whereami} | \myreflink{worldrectgrid} | \myreflink{worldrectcoast} | \myreflink{worldrectangular} | \myreflink{xyzw2cube} | \myreflink{yeardecimal} | \myreflink{zonal_stats} | |
7373

7474
## Solids functions
7575

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# anaglyph
2+
3+
```julia
4+
I = anaglyph(G|fname; vscale=1, sscale=2, kw...)
5+
```
6+
7+
---
8+
9+
```julia
10+
I = anaglyph(G|fname; view3d::Bool=false, zsize=4, azim=190, dazim=2, cmap="gray", kw...)
11+
```
12+
13+
---
14+
15+
Generate an anaglyph image from the input \myreflink{GMTgrid} `G` or grid's file name `fname`.
16+
17+
An anaglyph 3D is the stereoscopic 3D effect achieved by means of encoding each eye's image using
18+
filters of different (usually chromatically opposite) colors, typically red and cyan. Anaglyph 3D
19+
images contain two differently filtered colored images, one for each eye. When viewed through the
20+
"color-coded" "anaglyph glasses", each of the two images is visible to the eye it is intended for,
21+
revealing an integrated stereoscopic image (ref [Wiki](https://en.wikipedia.org/wiki/Anaglyph_3D)).
22+
23+
This function offers two methods to create anaglyphs from a gridded terrain model. The first one,
24+
based on a simple gradient of the surface elevation, is very fast, takes a little while to fool
25+
the brain (that is, to make it think it's looking into a true 3D surface) but gives a very impressive
26+
feeling of depth. The second method, that generates 2 3D views using the \myreflink{grdview} program
27+
and construct the anaglyph from those two images, is slower and creates a less perceptually depth
28+
image but it is easier to see and displays more 3D info.
29+
30+
### Args
31+
- `G`: The input \myreflink{GMTgrid} or filename of data to be processed.
32+
33+
### Kwargs
34+
- `vscale`: Terrain vertical scale factor (default: 1). Applies only to first method.
35+
36+
- `sscale`: Stereo separation scale factor (default: 2). Applies only to first method.
37+
38+
- `R`: Region of interest when reading a grid from disk (default: entire grid).
39+
Ignored when `G` is a GMTgrid.
40+
41+
- `view3d`: If true, selects an alternative and slower method that generates 2 3D views using
42+
the \myreflink{grdview} program and construct the anaglyph from those two images (default: false).
43+
44+
- `zsize`: z-axis size of the 3D view. Same as in \myreflink{grdview} (default: 4 cm).
45+
46+
- `azim`: Azimuth of the 3D view (default: 190).
47+
48+
- `dazim`: Azimuth step (default: 2). It means, create the anaglyph from the pair of images obtained
49+
with `azim` and `azim - dazim`.
50+
51+
- `cmap`: Color map (default: "gray").
52+
53+
### Returns
54+
An anaglyph \myreflink{GMTimage} suitable for viewing with red-cyan glasses.
55+
56+
### Credits
57+
The method that uses the grid's gradient is based on an ancient program called ManipRaster by Tierrt Souriot.
58+
The second method, the one that uses the \myreflink{grdview} program, was proposed by Tim Hume in the GMT forum.
59+
(https://forum.generic-mapping-tools.org/t/bringing-the-third-dimension-to-gmt-stereograms/6189)
60+
61+
62+
Examples
63+
--------
64+
65+
Create an anaglyph of first type overt the Iberian peninsula.
66+
67+
\begin{examplefig}{}
68+
```julia
69+
using GMT
70+
71+
I = anaglyph("@earth_relief_30s", region="-13/-5.5/35/44")
72+
viz(I)
73+
```
74+
\end{examplefig}
75+
76+
Now let us see the Tonga Trench using the second method.
77+
78+
79+
\begin{examplefig}{}
80+
```julia
81+
using GMT
82+
83+
I = anaglyph("@earth_relief_30s", R="-175.8/-171/-23/-14", view3d=true)
84+
viz(I)
85+
```
86+
\end{examplefig}

0 commit comments

Comments
 (0)