Skip to content

Commit 3a45183

Browse files
authored
Merge pull request #79 from JuliaImages/teh/newdocs
Minor improvements to docs
2 parents 8d2950f + ddd47a7 commit 3a45183

File tree

10 files changed

+76
-16
lines changed

10 files changed

+76
-16
lines changed

docs/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ ImageDraw = "4381153b-2b60-58ae-a1ba-fd683676385f"
55
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
66
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
77
TestImages = "5e47fb64-e119-507b-a336-dd2b206d9990"
8+
9+
[compat]
10+
Documenter = "0.24"

docs/make.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ using Documenter, ImageFeatures
33
makedocs(sitename = "ImageFeatures",
44
format = Documenter.HTML(prettyurls = get(ENV, "CI", nothing) == "true"),
55
pages = ["Home" => "index.md",
6+
"Framework" => "framework.md",
67
"Tutorials" => [
78
"BRIEF" => "tutorials/brief.md",
89
"ORB" => "tutorials/orb.md",

docs/src/framework.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# High-level overview of the framework
2+
3+
The `Feature` and `Keypoint` types are the main fundamental types in ImageFeatures.jl.
4+
`Feature` stores the `keypoint` and its `orientation` and `scale`. A vector of the `Feature` type is denoted by the `Features` type and similary a vector of `Keypoint` type is denoted by the `Keypoints` type. We provide multiple methods for easily transitioning between the two types.
5+
6+
`Keypoints` or `Features` can be generated from an image of boolean values by `Keypoints(boolean_image)` or `Features(boolean_image)` where the boolean_image may be obtained from a feature detection algorithm for, e.g., the result of a corner detector. All feature detectors in ImageFeatures.jl directly return `Features`.
7+
8+
A keypoint may be converted to a feature or vice versa by directly passing it to the respective method eg. `Keypoint(feature_A)` or `Feature(keypoint_A)`.
9+
10+
```julia
11+
descriptor, ret_keypoints = create_descriptor(img, params)
12+
descriptor, ret_keypoints = create_descriptor(img, keypoints, params)
13+
```
14+
15+
Depending on the algorithm , the `create_descriptor` API can be used to directly create a feature descriptor from the image (eg. ORB, BRISK) or from the keypoints (eg. BRIEF, FREAK). In case of the latter, the keypoints can be obtained using algorithms such as FAST. The `params` argument is dependent on the algorithm chosen and its type is the name of the algorithm.

docs/src/function_reference.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ FREAK
1515
BRISK
1616
```
1717

18-
## Corners
18+
## Corners and edges
1919

2020
```@docs
2121
corner_orientations
22+
fastcorners
23+
canny
24+
phase
2225
```
2326

2427
## BRIEF Sampling Patterns
@@ -87,6 +90,7 @@ multi_block_lbp
8790
# Misc
8891

8992
```@docs
93+
HOG
9094
hough_transform_standard
9195
hough_circle_gradient
9296
```

docs/src/tutorials/brief.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ img2 = warp(img1, trans, axes(img1));
3131
nothing # hide
3232
```
3333

34-
To calculate the descriptors, we first need to get the keypoints. For this tutorial, we will use the FAST corners to generate keypoints (see [`fastcorners`](@ref).
34+
To calculate the descriptors, we first need to get the keypoints. For this tutorial, we will use the FAST corners to generate keypoints (see [`fastcorners`](@ref)).
3535

3636
```@example 1
3737
keypoints_1 = Keypoints(fastcorners(img1, 12, 0.4))

docs/src/tutorials/brisk.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The *BRISK* descriptor has a predefined sampling pattern as compared to [BRIEF](brief.md) or [ORB](orb.md). Pixels are sampled over concentric rings. For each sampling point, a small patch is considered around it. Before starting the algorithm, the patch is smoothed using gaussian smoothing.
1+
The *BRISK* (Binary Robust Invariant Scalable Keypoints) descriptor has a predefined sampling pattern as compared to [BRIEF](brief.md) or [ORB](orb.md). Pixels are sampled over concentric rings. For each sampling point, a small patch is considered around it. Before starting the algorithm, the patch is smoothed using gaussian smoothing.
22

33
![BRISK Sampling Pattern](../img/brisk_pattern.png)
44

@@ -29,7 +29,7 @@ img2 = warp(img1, tform, axes(img1))
2929
nothing # hide
3030
```
3131

32-
To calculate the descriptors, we first need to get the keypoints. For this tutorial, we will use the FAST corners to generate keypoints (see [`fastcorners`](@ref).
32+
To calculate the descriptors, we first need to get the keypoints. For this tutorial, we will use the FAST corners to generate keypoints (see [`fastcorners`](@ref)).
3333

3434
```@example 4
3535
features_1 = Features(fastcorners(img1, 12, 0.35))

docs/src/tutorials/freak.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*FREAK* has a defined sampling pattern like [BRISK](brisk.md). It uses a retinal sampling grid with more density of points near the centre
1+
*FREAK* (Fast REtinA Keypoint) has a defined sampling pattern like [BRISK](brisk.md). It uses a retinal sampling grid with more density of points near the centre
22
with the density decreasing exponentially with distance from the centre.
33

44
![FREAK Sampling Pattern](../img/freak_pattern.png)
@@ -25,7 +25,7 @@ img2 = warp(img1, tform, axes(img1))
2525
nothing # hide
2626
```
2727

28-
To calculate the descriptors, we first need to get the keypoints. For this tutorial, we will use the FAST corners to generate keypoints (see [`fastcorners`](@ref).
28+
To calculate the descriptors, we first need to get the keypoints. For this tutorial, we will use the FAST corners to generate keypoints (see [`fastcorners`](@ref)).
2929

3030
```@example 3
3131
keypoints_1 = Keypoints(fastcorners(img1, 12, 0.35))

docs/src/tutorials/object_detection.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ Download the script to get the training data [here](https://drive.google.com/fil
1313
```julia
1414
using Images, ImageFeatures
1515

16-
path_to_tutorial = ""
17-
pos_examples = "path_to_tutorial/tutorial/humans/"
18-
neg_examples = "path_to_tutorial/tutorial/not_humans/"
16+
path_to_tutorial = "" # specify this path
17+
pos_examples = "$path_to_tutorial/tutorial/humans/"
18+
neg_examples = "$path_to_tutorial/tutorial/not_humans/"
1919

2020
n_pos = length(readdir(pos_examples)) # number of positive training examples
2121
n_neg = length(readdir(neg_examples)) # number of negative training examples
2222
n = n_pos + n_neg # number of training examples
23-
data = Array{Float64}(3780, n) # Array to store HOG descriptor of each image. Each image in our training data has size 128x64 and so has a 3780 length
24-
labels = Vector{Int}(n) # Vector to store label (1=human, 0=not human) of each image.
23+
data = Array{Float64}(undef, 3780, n) # Array to store HOG descriptor of each image. Each image in our training data has size 128x64 and so has a 3780 length
24+
labels = Vector{Int}(undef, n) # Vector to store label (1=human, 0=not human) of each image.
2525

2626
for (i, file) in enumerate([readdir(pos_examples); readdir(neg_examples)])
2727
filename = "$(i <= n_pos ? pos_examples : neg_examples )/$file"

docs/src/tutorials/orb.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The *ORB* descriptor is a somewhat similar to [BRIEF](brief.md). It doesn’t have an elaborate sampling pattern as [BRISK](brisk.md) or [FREAK](freak.md).
1+
The *ORB* (Oriented Fast and Rotated Brief) descriptor is a somewhat similar to [BRIEF](brief.md). It doesn’t have an elaborate sampling pattern as [BRISK](brisk.md) or [FREAK](freak.md).
22

33
However, there are two main differences between ORB and BRIEF:
44

src/glcm.jl

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
"""
2+
glcm = glcm(img, distance, angle, mat_size=16)
3+
glcm = glcm(img, distances, angle, mat_size=16)
4+
glcm = glcm(img, distance, angles, mat_size=16)
5+
glcm = glcm(img, distances, angles, mat_size=16)
6+
7+
Calculates the GLCM (Gray Level Co-occurence Matrix) of an image. The `distances` and `angles` arguments may be
8+
a single integer or a vector of integers if multiple GLCMs need to be calculated. The `mat_size` argument is used
9+
to define the granularity of the GLCM.
10+
"""
111
function glcm(img::AbstractArray{T, 2}, distance::Integer, angle::Real, mat_size::Integer = 16) where T<:Real
212
max_img = maximum(img)
313
img_rescaled = map(i -> max(1, Int(ceil(i * mat_size / max_img))), img)
@@ -45,31 +55,58 @@ function _glcm(img::AbstractArray{T, 2}, distance::Integer, angle::Number, mat_s
4555
co_oc_matrix
4656
end
4757

48-
function glcm_symmetric(img::AbstractArray, distance::Integer, angle::Real, mat_size)
58+
"""
59+
glcm = glcm_symmetric(img, distance, angle, mat_size=16)
60+
glcm = glcm_symmetric(img, distances, angle, mat_size=16)
61+
glcm = glcm_symmetric(img, distance, angles, mat_size=16)
62+
glcm = glcm_symmetric(img, distances, angles, mat_size=16)
63+
64+
Symmetric version of the [`glcm`](@ref) function.
65+
"""
66+
function glcm_symmetric(img::AbstractArray, distance::Integer, angle::Real, mat_size=16)
4967
co_oc_matrix = glcm(img, distance, angle, mat_size)
5068
co_oc_matrix_trans = co_oc_matrix'
5169
co_oc_matrix_symm = co_oc_matrix + co_oc_matrix_trans
5270
co_oc_matrix_symm
5371
end
5472

55-
function glcm_symmetric(img::AbstractArray, distances, angles, mat_size)
73+
function glcm_symmetric(img::AbstractArray, distances, angles, mat_size=16)
5674
co_oc_matrices = glcm(img, distances, angles, mat_size)
5775
co_oc_matrices_sym = map(gmat -> gmat + gmat', co_oc_matrices)
5876
co_oc_matrices_sym
5977
end
6078

61-
function glcm_norm(img::AbstractArray, distance::Integer, angle::Real, mat_size)
79+
"""
80+
glcm = glcm_norm(img, distance, angle, mat_size)
81+
glcm = glcm_norm(img, distances, angle, mat_size)
82+
glcm = glcm_norm(img, distance, angles, mat_size)
83+
glcm = glcm_norm(img, distances, angles, mat_size)
84+
85+
Normalised version of the [`glcm`](@ref) function.
86+
"""
87+
function glcm_norm(img::AbstractArray, distance::Integer, angle::Real, mat_size=16)
6288
co_oc_matrix = glcm(img, distance, angle, mat_size)
6389
co_oc_matrix_norm = co_oc_matrix / Float64(sum(co_oc_matrix))
6490
co_oc_matrix_norm
6591
end
6692

67-
function glcm_norm(img::AbstractArray, distances, angles, mat_size)
93+
function glcm_norm(img::AbstractArray, distances, angles, mat_size=16)
6894
co_oc_matrices = glcm(img, distances, angles, mat_size)
6995
co_oc_matrices_norm = map(gmat -> gmat /= Float64(sum(gmat)), co_oc_matrices)
7096
co_oc_matrices_norm
7197
end
7298

99+
"""
100+
Multiple properties of the obtained GLCM can be calculated by using the `glcm_prop` function which calculates the
101+
property for the entire matrix. If grid dimensions are provided, the matrix is divided into a grid and the property
102+
is calculated for each cell resulting in a height x width property matrix.
103+
```julia
104+
prop = glcm_prop(glcm, property)
105+
prop = glcm_prop(glcm, height, width, property)
106+
```
107+
Various properties can be calculated like `mean`, `variance`, `correlation`, `contrast`, `IDM` (Inverse Difference Moment),
108+
`ASM` (Angular Second Moment), `entropy`, `max_prob` (Max Probability), `energy` and `dissimilarity`.
109+
"""
73110
function glcm_prop(gmat::Array{T, 2}, window_height::Integer, window_width::Integer, property::Function) where T<:Real
74111
k_h = Int(floor(window_height / 2))
75112
k_w = Int(floor(window_width / 2))

0 commit comments

Comments
 (0)