Skip to content

Commit 517de87

Browse files
committed
Add two
1 parent 6bc0db9 commit 517de87

File tree

4 files changed

+92
-5
lines changed

4 files changed

+92
-5
lines changed

documentation/all_docs_ref/all_refs.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,9 @@ its use requires resorting to the \myreflink{Monolithic} mode.
6464
| | | | | | | | |
6565
|:-----|:----|:----|:----|:----|:----|:----|:----|
6666
| \myreflink{binarize} | \myreflink{bwhitmiss} | \myreflink{bwperim} | \myreflink{bwskell} | \myreflink{fillsinks} | \myreflink{imbothat} | \myreflink{imclose} | \myreflink{imcomplement} |
67-
| \myreflink{imdilate} | \myreflink{imerode} | \myreflink{imfill} | \myreflink{imhdome} | \myreflink{imhmin} | \myreflink{imhmax} | \myreflink{immorphgrad} | \myreflink{imopen} |
68-
| \myreflink{imreconstruct} | \myreflink{imrankfilter} | \myreflink{imsegment} | \myreflink{imtophat} | \myreflink{isodata} | \myreflink{padarray} | \myreflink{strel} | \myreflink{rgb2gray} |
69-
| \myreflink{rgb2lab} | \myreflink{rgb2ycbcr} | | | | | | |
70-
67+
| \myreflink{imdilate} | \myreflink{imerode} | \myreflink{imfill} | \myreflink{imfilter} | \myreflink{imhdome} | \myreflink{imhmin} | \myreflink{imhmax} | \myreflink{immorphgrad} |
68+
| \myreflink{imopen} | \myreflink{imrankfilter} | \myreflink{imreconstruct} | \myreflink{imsegment} | \myreflink{imsobel} | \myreflink{imtophat} | \myreflink{isodata} | \myreflink{padarray} |
69+
| \myreflink{strel} | \myreflink{rgb2gray} | \myreflink{rgb2lab} | \myreflink{rgb2ycbcr} | | | | |
7170

7271
## GDAL utility functions
7372

documentation/utilities/imfill.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Example from Matlab imfill.
3636
```julia
3737
using GMT
3838

39-
I = gdalread(GMT.TESTSDIR * "assets/coins.jpg");
39+
I = gdalread(TESTSDIR * "assets/coins.jpg");
4040
Ibw1 = binarize(I);
4141
Ibw2 = imfill(Ibw1);
4242
grdimage(I, figsize=5)

documentation/utilities/imfilter.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# imfilter
2+
3+
```julia
4+
J = imfilter(I::GMTimage, kernel::Matrix{<:Real}; normalize::Int=1)::GMTimage
5+
```
6+
7+
*keywords: GMT, Julia, fill convolution filtering*
8+
9+
### Args
10+
- `I::GMTimage`: Input image. This can be a RGB or grayscale image.
11+
- `kernel::Matrix{<:Real}`: The filter kernel MxN matrix.
12+
13+
### Kwargs
14+
- `normalize::Int=1`: Normalize the filter to unit sum. This is the default, unless ``sum(kernel) == 0``,
15+
case in which we change it to 0.
16+
17+
### Returns
18+
A new \myreflink{GMTimage} of the same type as `I` with the filtered image.
19+
20+
Example
21+
-------
22+
23+
Apply an 3x3 Mean Removal filter to the image "moon.png".
24+
25+
\begin{examplefig}{}
26+
```julia
27+
using GMT
28+
29+
I = gmtread(TESTSDIR * "assets/moon.png");
30+
J = imfilter(I, [-1 -1 -1; -1 9 -1; -1 -1 -1]);
31+
grdimage(I, figsize=5)
32+
grdimage!(J, figsize=5, xshift=5, show=true)
33+
```
34+
\end{examplefig}
35+
36+
See Also
37+
--------
38+
39+
\myreflink{imfill}, \myreflink{bwskell}, \myreflink{imerode}, \myreflink{imsobel}

documentation/utilities/imsobel.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# imsobel
2+
3+
```julia
4+
J = imsobel(I::GMTimage{<:UInt8, 2}; direction::Int=2)::GMTimage
5+
```
6+
7+
*keywords: GMT, Julia, Sobel filter*
8+
9+
Sobel edge detecting filter.
10+
11+
Returns a binary \myreflink{GMTimage} containing 1s where the function finds edges in the grayscale or binary image I and 0s elsewhere.
12+
13+
### Args
14+
- `I::GMTimage`: Input grayscale image.
15+
16+
### Kwargs
17+
- `direction::Int=2`: Orientation flag: `0` means detect horizontal edges, `1` means vertical and `2` means all edges.
18+
19+
### Returns
20+
- A new \myreflink{GMTimage} grayscale image `I` with the edge detection, edges are brighter.
21+
22+
Example
23+
-------
24+
25+
Let us vectorize the rice grains in the image "rice.png". The result is not perfect because
26+
the grains in the image's edge are not closed and therefore not filled. And those get poligonized
27+
twice (in and outside) making the red lines look thicker (but they are not, they are just doubled).
28+
29+
\begin{examplefig}{}
30+
```julia
31+
using GMT
32+
33+
I = gmtread(TESTSDIR * "assets/rice.png");
34+
J = imsobel(I);
35+
BW = binarize(J);
36+
BW = bwskell(BW); # Skeletize to get a better approximation of the shapes.
37+
BW = imfill(BW); # Fill to avoid "double" vectorization (outside and inside grain outline)
38+
D = polygonize(BW);
39+
grdimage(I, figsize=5)
40+
grdimage!(J, figsize=5, xshift=5.05)
41+
grdimage!(BW, figsize=5, xshift=-5.05, yshift=-5.05)
42+
grdimage!(I, figsize=5, xshift=5.05, plot=(data=D, lc=:red), show=true)
43+
```
44+
\end{examplefig}
45+
46+
See Also
47+
--------
48+
49+
\myreflink{imfill}, \myreflink{bwskell}, \myreflink{imerode}, \myreflink{imfilter}

0 commit comments

Comments
 (0)