Skip to content

Commit 08d48ce

Browse files
committed
Add man pages
1 parent 8297c70 commit 08d48ce

12 files changed

+521
-0
lines changed

documentation/utilities/binarize.md

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# binarize
2+
3+
```julia
4+
Ibw = binarize(I::GMTimage, threshold::Int=0; band=1, revert=false) -> GMTimage
5+
```
6+
7+
Convert an image to a binary image (black-and-white) using a threshold.
8+
9+
### Args
10+
- `I::GMTimage`: input image of type UInt8.
11+
12+
- `threshold::Int`: A number in the range [0 255]. If the default (`nothing`) is maintained,
13+
the threshold is computed using the \myreflink{isodata} method.
14+
15+
### Kwargs
16+
- band: If the `I` image has more than one band, use `band` to specify which one to binarize.
17+
18+
- `revert`: If `true`, values below the threshold are set to 255, and values above the threshold are set to 0.
19+
20+
### Return
21+
A new \myreflink{GMTimage}.
22+
23+
24+
Example
25+
-------
26+
27+
\begin{examplefig}{}
28+
```julia
29+
using GMT
30+
31+
I = gdalread(GMT.TESTSDIR * "assets/coins.jpg");
32+
Ibw = binarize(I, band=1)
33+
34+
# Show the two side-by-side
35+
grdimage(I, figsize=6)
36+
grdimage!(Ibw, figsize=6, xshift=6.1, show=true)
37+
```
38+
\end{examplefig}
39+
40+
41+
See Also
42+
--------
43+
44+
\myreflink{imcomplement}

documentation/utilities/imclose.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# imclose
2+
3+
```julia
4+
J = imclose(I::Union{GMTimage{<:UInt8, 2}, GMTimage{<:Bool, 2}}; hsize=3, vsize=3, sel=nothing)::GMTimage
5+
```
6+
7+
*keywords: GMT, Julia, image morphology, closing*
8+
9+
Close the grayscale or binary image I.
10+
11+
The morphological close operation is a dilation followed by an erosion, using the same structuring element
12+
for both operations.
13+
The closing is performed with a matrix of 0’s and 1’s with width `hsize` and height `vsize`, or, if possible,
14+
with the structuring element \myreflink{strel}. Later case is faster but it is only available for binary images, where by
15+
_binary_ images we mean Boolean images or images with only 0’s and 1’s of UInt8 type.
16+
17+
### Returns
18+
A new \myreflink{GMTimage} of the same type as `I` with the closing applied.
19+
20+
Example
21+
-------
22+
23+
Erosion with a disk radius of 10, 5 and 20
24+
25+
\begin{examplefig}{}
26+
```julia
27+
using GMT
28+
29+
I = gmtread(TESTSDIR * "assets/packman.png");
30+
J = imclose(I, sel=strel("box", 20));
31+
grdimage(I, figsize=7)
32+
grdimage!(J, figsize=7, xshift=7.1, show=true)
33+
```
34+
\end{examplefig}
35+
36+
37+
See Also
38+
--------
39+
40+
\myreflink{imdilate}, \myreflink{imerode}, \myreflink{imopeb}, \myreflink{strel}
+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# imcomplement
2+
3+
```julia
4+
J = imcomplement(I::GMTimage) -> GMTimage
5+
```
6+
7+
*keywords: GMT, Julia, image processing*
8+
9+
Compute the complement of the image `I` and returns the result in `J`.
10+
11+
`I` can be a binary, intensity, or truecolor image. `J` has the same type and size as `I`. `I` can
12+
also be just a matrix. All types numeric (but complex) are allowed.
13+
14+
In the complement of a binary image, black becomes white and white becomes black. In the case of a
15+
grayscale or truecolor image, dark areas become lighter and light areas become darker.
16+
17+
The ``imcomplement!`` function works in-place and returns the modified ``I``.
18+
19+
### Returns
20+
- A new \myreflink{GMTimage}
21+
22+
Example
23+
-------
24+
25+
Reverse Black and White in a Binary Image.
26+
27+
\begin{examplefig}{}
28+
```julia
29+
using GMT
30+
31+
text(["Hello World"], region=(1.92,2.08,1.97,2.02), x=2.0, y=2.0,
32+
font=(30, "Helvetica-Bold", :white),
33+
frame=(axes=:none, bg=:black), figsize=(6,0), name="tmp.png")
34+
35+
# Read only one band (althouh gray scale, the "tmp.png" is actually RGB)
36+
I = gmtread("tmp.png", band=1);
37+
Ic = imcomplement(I);
38+
39+
# Show the two
40+
grdimage(I, figsize=8)
41+
grdimage!(Ic, figsize=8, yshift=-2.57, show=true)
42+
```
43+
\end{examplefig}
44+
45+
Create the Complement of a Color Image
46+
47+
\begin{examplefig}{}
48+
```julia
49+
using GMT
50+
51+
I = gmtread(GMT.TESTSDIR * "assets/table_flowers.jpg");
52+
Ic = imcomplement(I);
53+
54+
grdimage(I, figsize=6)
55+
grdimage!(Ic, figsize=6, xshift=6, show=true)
56+
```
57+
\end{examplefig}
58+
59+
See Also
60+
--------
61+
62+
\myreflink{binarize}

documentation/utilities/imdilate.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# imdilate
2+
3+
```julia
4+
J = imdilate(I::Union{GMTimage{<:UInt8, 2}, GMTimage{<:Bool, 2}}; hsize=3, vsize=3, sel=nothing)::GMTimage
5+
```
6+
7+
*keywords: GMT, Julia, image morphology, dilation*
8+
9+
Dilate the grayscale or binary image I.
10+
11+
The dilation is performed with a matrix of 0’s and 1’s with width `hsize` and height `vsize`, or, if possible,
12+
with the structuring element \myreflink{strel}. Later case is faster but it is only available for binary images,
13+
where by _binary_ images we mean Boolean images or images with only 0’s and 1’s of UInt8 type.
14+
15+
### Returns
16+
A new \myreflink{GMTimage} of the same type as `I` with the dilation applied.
17+
18+
### Example
19+
Dilation with a square of width 3 (the default when neither `sel`, nor `hsize` or `vsize` are specified)
20+
21+
Examples
22+
--------
23+
24+
Erosion with a disk radius of 10, 5 and 20
25+
26+
\begin{examplefig}{}
27+
```julia
28+
using GMT
29+
30+
I = gmtread(TESTSDIR * "assets/fig_text_bw.png");
31+
J = imdilate(I);
32+
grdimage(I, figsize=7)
33+
grdimage!(J, figsize=7, xshift=7.1, show=true)
34+
```
35+
\end{examplefig}
36+
37+
38+
See Also
39+
--------
40+
41+
\myreflink{imerode}, \myreflink{imopen}, \myreflink{imclose}, \myreflink{strel}

documentation/utilities/imerode.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# imerode
2+
3+
```julia
4+
J = imerode(I::Union{GMTimage{<:UInt8, 2}, GMTimage{<:Bool, 2}}; hsize=3, vsize=3, sel=nothing)::GMTimage
5+
```
6+
7+
*keywords: GMT, Julia, image morphology, erosion*
8+
9+
Erode the grayscale or binary image I.
10+
11+
The erosion is performed with a matrix of 0’s and 1’s with width `hsize` and height `vsize`, or, if possible,
12+
with the structuring element \myreflink{strel}. Later case is faster but it is only available for binary images,
13+
where by _binary_ images we mean Boolean images or images with only 0’s and 1’s of UInt8 type.
14+
15+
### Returns
16+
A new \myreflink{GMTimage} of the same type as `I` with the erosion applied.
17+
18+
Examples
19+
--------
20+
21+
Erosion with a disk radius of 10, 5 and 20
22+
23+
\begin{examplefig}{}
24+
```julia
25+
using GMT
26+
27+
I = gmtread(TESTSDIR * "assets/chip.png");
28+
J1 = imerode(I, sel=strel("disk", 10));
29+
J2 = imerode(I, sel=strel("disk", 5));
30+
J3 = imerode(I, sel=strel("disk", 20));
31+
grdimage(I, figsize=6)
32+
grdimage!(J1, figsize=6, xshift=6.1)
33+
grdimage!(J2, figsize=6, xshift=-6.1, yshift=-6.1)
34+
grdimage!(J3, figsize=6, xshift=-6.1, show=true)
35+
```
36+
\end{examplefig}
37+
38+
39+
See Also
40+
--------
41+
42+
\myreflink{imdilate}, \myreflink{imopen}, \myreflink{imclose}, \myreflink{strel}

documentation/utilities/imopen.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# imopen
2+
3+
```julia
4+
J = imopen(I::Union{GMTimage{<:UInt8, 2}, GMTimage{<:Bool, 2}}; hsize=3, vsize=3, sel=nothing)::GMTimage
5+
```
6+
7+
*keywords: GMT, Julia, image morphology, opening*
8+
9+
Open the grayscale or binary image I.
10+
11+
The morphological opening operation is an erosion followed by a dilation, using the same structuring
12+
element for both operations.
13+
The opening is performed with a matrix of 0’s and 1’s with width `hsize` and height `vsize`, or, if possible,
14+
with the structuring element \myreflink{strel}. Later case is faster but it is only available for binary images, where by
15+
_binary_ images we mean Boolean images or images with only 0’s and 1’s of UInt8 type.
16+
17+
### Returns
18+
A new \myreflink{GMTimage} of the same type as `I` with the opening applied.
19+
20+
Example
21+
-------
22+
23+
Erosion with a disk radius of 10, 5 and 20
24+
25+
\begin{examplefig}{}
26+
```julia
27+
using GMT
28+
29+
I = gmtread(TESTSDIR * "assets/packman.png");
30+
J = imopen(I, sel=strel("box", 20));
31+
grdimage(I, figsize=7)
32+
grdimage!(J, figsize=7, xshift=7.1, show=true)
33+
```
34+
\end{examplefig}
35+
36+
37+
See Also
38+
--------
39+
40+
\myreflink{imdilate}, \myreflink{imerode}, \myreflink{imclose}, \myreflink{strel}

documentation/utilities/isodata.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# isodata
2+
3+
```julia
4+
level = isodata(I::GMTimage; band=1) -> Int
5+
```
6+
7+
Compute global image threshold using iterative isodata method.
8+
9+
It can be used to convert
10+
an intensity image to a binary image with \myreflink{binarize}. `level` is a normalized intensity value that lies
11+
in the range [0 255]. This iterative technique for choosing a threshold was developed by Ridler and Calvard.
12+
The histogram is initially segmented into two parts using a starting threshold value such as 0 = 2B-1,
13+
half the maximum dynamic range. The sample mean (mf,0) of the gray values associated with the foreground
14+
pixels and the sample mean (mb,0) of the gray values associated with the background pixels are computed.
15+
A new threshold value 1 is now computed as the average of these two sample means. The process is repeated,
16+
based upon the new threshold, until the threshold value does not change any more.
17+
18+
Originaly from MATLAB http://www.mathworks.com/matlabcentral/fileexchange/3195 (BSD, Licenced)
19+
20+
### Args
21+
- `I::GMTimage`: input image of type UInt8.
22+
23+
### Kwargs
24+
- band: If the `I` image has more than one band, use `band` to specify which one to use.
25+
26+
### Returns
27+
An integer value that lies in the range [0 255].
28+
29+
Example
30+
-------
31+
32+
```jldoctest
33+
I = gmtread(GMT.TESTSDIR * "assets/coins.jpg");
34+
level = isodata(I, band=1)
35+
119
36+
```

documentation/utilities/padarray.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# padarray
2+
3+
```julia
4+
B = padarray(A, padsize; padval=nothing)
5+
```
6+
7+
Pad matrix A with an amount of padding in each dimension specified by padsize.
8+
9+
### Args
10+
- `A`: GMTimage, GMTgrid or Matrix to pad.
11+
12+
- `padsize`: Amount of padding in each dimension. It can be a scalar or a array of length
13+
equal to 2 (only matrices are supported).
14+
15+
### Kwargs
16+
- `padval`: If not specified, `A` is padded with a replication of the first/last row and column, otherwise
17+
`padval` specifies a constant value to use for padded elements. `padval` can take the value -Inf or Inf,
18+
in which case the smallest or largest representable value of the type of `A` is used, respectively.
19+
20+
### Return
21+
Padded array of same type as input.
22+
23+
Example
24+
-------
25+
26+
```jldoctest
27+
A = [1 2; 3 4];
28+
B = padarray(A,1)
29+
4×4 Matrix{Int64}:
30+
1 1 2 2
31+
1 1 2 2
32+
3 3 4 4
33+
3 3 4 4
34+
```

documentation/utilities/rgb2gray.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# rgb2gray
2+
3+
```julia
4+
Igray = rgb2gray(I::GMTimage{UInt8, 3}) -> GMTimage{UInt8, 2}
5+
```
6+
7+
Convert an RGB image to a grayscale image applying the television YMQ transformation.
8+
9+
### Args
10+
- `I::GMTimage{UInt8, 3}`: input image of type UInt8.
11+
12+
### Returns
13+
A new ``GMTimage{UInt8, 2}``.
14+
15+
16+
Example
17+
-------
18+
19+
\begin{examplefig}{}
20+
```julia
21+
using GMT
22+
23+
I = gmtread(GMT.TESTSDIR * "assets/bunny_cenora.jpg");
24+
Igray = rgb2gray(I)
25+
26+
# Show the two side-by-side
27+
grdimage(I, figsize=6)
28+
grdimage!(Igray, figsize=6, xshift=6.1, show=true)
29+
```
30+
\end{examplefig}

0 commit comments

Comments
 (0)