You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/modules/contourf.md
+31-7Lines changed: 31 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,16 @@ Create filled contour mapps.
9
9
Description
10
10
-----------
11
11
12
-
This module is a wrapper to \myreflink{grdview}, *contour* and \myreflink{grdcontour} and as such it works with two different kinds of input data. If input is a grid (either a grid file name or a GMTgrid object) it will make a filled contour with *grdview* and optionally overlay contours by calling \myreflink{grdcontour}. If, on the other hand, the input data is table data file or a Mx3 array (or GMTdataset), it first compute a Delaunay triangulation and makes the plot from it. In this later case, the job is done by *contour* module alone.
12
+
This module is a wrapper to \myreflink{grdview}, *contour* and \myreflink{grdcontour} and as such it works with two
13
+
different kinds of input data. If input is a grid (either a grid file name or a GMTgrid object) it will make a filled
14
+
contour with *grdview* and optionally overlay contours by calling \myreflink{grdcontour}. If, on the other hand,
15
+
the input data is table data file or a Mx3 array (or GMTdataset), it first compute a Delaunay triangulation and makes
16
+
the plot from it. In this later case, the job is done by *contour* module alone.
17
+
18
+
Optionaly one can plot the so called Tanaka contours. These are contour lines whose thickness and intensity vary based
19
+
on illumination direction, creating an illusion of 3D relief. Illuminated slopes get lighter/thinner lines, shaded slopes
20
+
get darker/thicker lines. This is a slow method (not to be used with large grids) but with a nice visual effect.
21
+
See the **tanaka** option.
13
22
14
23
The **region** option can be used to select a map region larger or smaller than that implied by the extent of the grid.
15
24
@@ -46,9 +55,9 @@ Optional Arguments
46
55
47
56
2. If ``cont_int`` is a constant or an array it means plot those contour intervals. This works also to draw
48
57
single contours. *E.g.***contour=[0]** will draw only the zero contour. The **annot** option offers the same
49
-
possibility so they may be used together to plot a single annotated contour and another single non-annotated contour,
50
-
as in **anot=[10], cont=[5]** that plots an annotated 10 contour and an non-annotated 5 contour. If **annot** is set
51
-
and **cont** is not, then the contour interval is set equal to the specified annotation interval.
58
+
possibility so they may be used together to plot a single annotated contour and another single non-annotated contour,
59
+
as in **anot=[10], cont=[5]** that plots an annotated 10 contour and an non-annotated 5 contour. If **annot** is set
60
+
and **cont** is not, then the contour interval is set equal to the specified annotation interval.
52
61
53
62
If no **contour** option and no *GMTcpt* are passed then for grid a default color map is computed and all of
54
63
those automatically contours are drwan. Also, no *GMTcpt* and **contour=[array]** computes a cmap with only the
@@ -79,7 +88,7 @@ Optional Arguments
79
88
80
89
-**S** or **skip** : -- *skip=true|"t"*\
81
90
Skip all input xyz points that fall outside the region [Default uses all the data in the triangulation].
82
-
Alternatively, use **skip="t"* to skip triangles whose three vertices are all outside the region.
91
+
Alternatively, use **skip="t"** to skip triangles whose three vertices are all outside the region.
83
92
*This option should be used only when input data is a grid*.
84
93
85
94
-**T** or **ticks** : -- *ticks=(local\_high=true, local\_low=true, gap=gap, closed=true, labels=labels)*\
@@ -93,6 +102,11 @@ Optional Arguments
93
102
label strings with a comma (*e.g.*, *labels="lo,hi"*). If a file is given by **cont**, and **ticks** is set,
94
103
then only contours marked with upper case C or A will have tick marks [and annotations].
-`8` — 8-connected neighborhood (edge and corner connectivity)
29
+
- Alternatively, can be a connectivity array of 0s and 1s with the same dimensionality as `BW`. The 1-valued elements define neighborhood locations relative to the center element. The center element must be 1. The connectivity array size must be odd along each dimension.
30
+
31
+
## Returns
32
+
33
+
Connected components, specified as a structure with the following fields:
34
+
35
+
| Field | Description |
36
+
|-------|-------------|
37
+
|`connectivity`| Connectivity of the connected components |
38
+
|`image_size`| Size of the binary image |
39
+
|`num_objects`| Number of connected components in the binary image |
40
+
|`range`| Range of the image coordinates |
41
+
|`inc`| Image's increment (!= 1 whem image is referenced) |
42
+
|`registration`| Registration of the image |
43
+
|`x`| X coordinates of the image |
44
+
|`y`| Y coordinates of the image |
45
+
|`layout`| Memory layout of the image |
46
+
|`proj4`| Projection definition (optional) |
47
+
|`wkt`| Well-known text definition (optional) |
48
+
|`epsg`| EPSG code of the image |
49
+
|`bbox`| The bounding boxes as a vector of GMTdataset |
50
+
|`pixel_list`| Vector where each element contains the linear indices of the pixels in each object |
51
+
|`centroid`| A Float64 Matrix with the x,y coordinates of the centroids for each component |
52
+
|`area`| A vector of Float64 with the areas of each component |
53
+
54
+
- To compute a label matrix with a memory-efficient data type (for instance, `UInt8` versus `Float64`),
55
+
use the `labelmatrix` function on the output of `bwconncomp`:
56
+
57
+
```julia
58
+
CC =bwconncomp(BW)
59
+
L =labelmatrix(CC)
60
+
```
61
+
62
+
## Examples
63
+
64
+
### Find Connected Components in Binary Image
65
+
66
+
```julia
67
+
using GMT
68
+
69
+
# Create a binary image
70
+
BW = [11000000
71
+
11011000
72
+
00011000
73
+
00000110
74
+
00000110
75
+
00000000]
76
+
77
+
# Find connected components
78
+
CC =bwconncomp(BW)
79
+
80
+
println("Number of connected components: ", CC.num_objects)
81
+
```
82
+
83
+
### Specify Connectivity
84
+
85
+
Find connected components using 4-connectivity instead of the default 8-connectivity:
86
+
87
+
```julia
88
+
using GMT
89
+
90
+
BW = [11000000
91
+
11011000
92
+
00011000
93
+
00000110
94
+
00000110
95
+
00000000]
96
+
97
+
# 4-connectivity
98
+
CC4 =bwconncomp(BW, conn=4)
99
+
println("Number of components (4-conn): ", CC4.num_objects)
100
+
101
+
# 8-connectivity
102
+
CC8 =bwconncomp(BW, conn=8)
103
+
println("Number of components (8-conn): ", CC8.num_objects)
104
+
```
105
+
106
+
### Extract Properties of Connected Components
107
+
108
+
Use the output structure to analyze individual components:
109
+
110
+
```julia
111
+
using GMT
112
+
113
+
BW = [11000000
114
+
11011000
115
+
00011000
116
+
00000110
117
+
00000110
118
+
00000000]
119
+
120
+
CC =bwconncomp(BW)
121
+
122
+
# Number of pixels in each component
123
+
numPixels = [length(CC.pixel_list[i]) for i in1:CC.num_objects]
124
+
println("Pixels per component: ", numPixels)
125
+
126
+
# Find the largest component
127
+
largest =argmax(numPixels)
128
+
println("Largest component is #", largest, " with ", numPixels[largest], " pixels")
0 commit comments