Skip to content

Commit 32105a9

Browse files
committed
freak docs, bug fixes
1 parent 13c4417 commit 32105a9

File tree

9 files changed

+71
-34
lines changed

9 files changed

+71
-34
lines changed

docs/src/tutorials/brief.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
To build a BRIEF descriptor of length `n`, we need to determine `n` pairs `(Xi,Yi)`. Denote by `X` and `Y` the vectors of point `Xi` and `Yi`, respectively.
44

55
In ImageFeatures.jl we have five methods to determine the vectors `X` and `Y` :
6-
- [`random_uniform`] : `X` and `Y` are randomly uniformly sampled
7-
- [`gaussian`] : `X` and `Y` are randomly sampled using a Gaussian distribution, meaning that locations that are closer to the center of the patch are preferred
8-
- [`gaussian_local`] : `X` and `Y` are randomly sampled using a Gaussian distribution where first `X` is sampled with a standard deviation of `0.04*S^2` and then the `Yi’s` are sampled using a Gaussian distribution – Each `Yi` is sampled with mean `Xi` and standard deviation of `0.01 * S^2`
9-
- [`random_coarse`] : `X and `Y` are randomly sampled from discrete location of a coarse polar grid
10-
- [`centered`] : For each `i`, `Xi` is `(0, 0)` and `Yi` takes all possible values on a coarse polar grid
6+
7+
- [random_uniform](`random_uniform`) : `X` and `Y` are randomly uniformly sampled
8+
- [gaussian](`gaussian`) : `X` and `Y` are randomly sampled using a Gaussian distribution, meaning that locations that are closer to the center of the patch are preferred
9+
- [gaussian_local](`gaussian_local`) : `X` and `Y` are randomly sampled using a Gaussian distribution where first `X` is sampled with a standard deviation of `0.04*S^2` and then the `Yi’s` are sampled using a Gaussian distribution – Each `Yi` is sampled with mean `Xi` and standard deviation of `0.01 * S^2`
10+
- [random_coarse](`random_coarse`) : `X` and `Y` are randomly sampled from discrete location of a coarse polar grid
11+
- [centered](`centered`) : For each `i`, `Xi` is `(0, 0)` and `Yi` takes all possible values on a coarse polar grid
1112

1213
As with all the binary descriptors, BRIEF’s distance measure is the number of different bits between two binary strings which can also be computed as the sum of the XOR operation between the strings.
1314

docs/src/tutorials/brisk.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ The *BRISK* descriptor has a predefined sampling pattern as compared to [BRIEF](
44

55
Two types of pairs are used for sampling, short and long pairs. Short pairs are those where the distance is below a set threshold distmax while the long pairs have distance above distmin. Long pairs are used for orientation and short pairs are used for calculating the descriptor by comparing intensities.
66

7-
![BRISK Long Pairs](/img/brisk_long_pairs.jpg = 50x50)
8-
![BRISK Short Pairs](/img/brisk_short_pairs.jpg = 50x50)
9-
107
BRISK achieves rotation invariance by trying the measure orientation of the keypoint and rotating the sampling pattern by that orientation. This is done by first calculating the local gradient `g(pi,pj)` between sampling pair `(pi,pj)` where `I(pj, pj)` is the smoothed intensity after applying gaussian smoothing.
118

129
`g(pi, pj) = (pi - pj) . I(pj, j) -I(pj, j)pj - pi2`

docs/src/tutorials/glcm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Once a spatial relationship is defined, we create a GLCM of size (Range of Intensities x Range of Intensities) all initialised to `0`. For eg, a `8` bit single channel Image will have a `256x256` GLCM. We then traverse through the image and for every pair of intensities we find for the defined spatial relationship, we increment that cell of the matrix.
44

5-
![Gray Level Co-occurence Matrix](/img/glcm.png = 50x50)
5+
![Gray Level Co-occurence Matrix](/img/glcm.png)
66

77
Each entry of the GLCM[i,j] holds the count of the number of times that pair of intensities appears in the image with the defined spatial relationship.
88

docs/src/tutorials/lbp.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
*Local Binary Pattern (LBP)* is a very efficient texture operator which labels the pixels of an image by thresholding the neighborhood of each pixel and considers the result as a binary number. The LBP feature vector, in its simplest form, is created in the following manner :
22

3-
![Local Binary Pattern](/img/lbp.png = 50x50)
3+
![Local Binary Pattern](/img/lbp.png)
44

55
- Divide the examined window into cells (e.g. 16x16 pixels for each cell).
66
- For each pixel in a cell, compare the pixel to each of its 8 neighbors (on its left-top, left-middle, left-bottom, right-top, etc.). Follow the pixels along a circle, i.e. clockwise or counterclockwise.
@@ -16,12 +16,12 @@ The feature vector can now then be processed using some machine-learning algorit
1616

1717
ImageFeatures.jl provides the following types of local binary patterns :
1818

19-
#### [`lbp`]
19+
#### [lbp](`lbp`)
2020

2121
The original local binary patterns
2222

23-
#### [`modified_lbp`]
23+
#### [modified_lbp](`modified_lbp`)
2424

25-
#### [`direction_coded_lbp`]
25+
#### [direction_coded_lbp](`direction_coded_lbp`)
2626

27-
#### [`multi_block_lbp`]
27+
#### [multi_block_lbp](`multi_block_lbp`)

src/brief.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
type BRIEF{F} <: DescriptorParams
2-
size::Int
3-
window::Int
4-
sigma::Float64
5-
sampling_type::F
6-
seed::Int
7-
end
8-
91
"""
102
```
113
brief_params = BRIEF([size = 128], [window = 9], [sigma = 2 ^ 0.5], [sampling_type = gaussian], [seed = 123])
@@ -20,6 +12,14 @@ brief_params = BRIEF([size = 128], [window = 9], [sigma = 2 ^ 0.5], [sampling_ty
2012
| `seed` | `Int` | Random seed used for generating the sampling pairs. For matching two descriptors, the seed used to build both should be same. |
2113
2214
"""
15+
type BRIEF{F} <: DescriptorParams
16+
size::Int
17+
window::Int
18+
sigma::Float64
19+
sampling_type::F
20+
seed::Int
21+
end
22+
2323
function BRIEF(; size::Integer = 128, window::Integer = 9, sigma::Float64 = 2 ^ 0.5, sampling_type::Function = gaussian, seed::Int = 123)
2424
BRIEF(size, window, sigma, sampling_type, seed)
2525
end

src/core.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,45 @@
11
abstract Detector
22
abstract DescriptorParams
3+
4+
"""
5+
```
6+
keypoint = Keypoint(y, x)
7+
```
8+
9+
The `Keypoint` type.
10+
"""
311
typealias Keypoint CartesianIndex{2}
12+
13+
"""
14+
```
15+
keypoints = Keypoints(boolean_img)
16+
```
17+
18+
Creates a `Vector{Keypoint}` of the true values in the `boolean_img`.
19+
"""
420
typealias Keypoints Vector{CartesianIndex{2}}
521

622
function Keypoints(img::AbstractArray)
723
r, c, _ = findnz(img)
824
map((ri, ci) -> Keypoint(ri, ci), r, c)
925
end
1026

27+
"""
28+
```
29+
distance = hamming_distance(desc_1, desc_2)
30+
```
31+
32+
Calculates the hamming distance between two descriptors.
33+
"""
1134
hamming_distance(desc_1, desc_2) = mean(desc_1 $ desc_2)
1235

36+
"""
37+
```
38+
matches = match_keypoints(keypoints_1, keypoints_2, desc_1, desc_2, threshold = 0.1)
39+
```
40+
41+
Finds matched keypoints using the [hamming_distance](`hamming_distance`) function having distance value less than `threshold`.
42+
"""
1343
function match_keypoints(keypoints_1::Keypoints, keypoints_2::Keypoints, desc_1, desc_2, threshold::Float64 = 0.1)
1444
smaller = desc_1
1545
larger = desc_2

src/corner.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ Returns the orientations of corner patches in an image. The orientation of a cor
99
is denoted by the orientation of the vector between intensity centroid and the corner.
1010
The intensity centroid can be calculated as `C = (m01/m00, m10/m00)` where mpq is defined as -
1111
12-
mpq = (x^p)(y^q)I(y, x) for each p, q in the corner patch
12+
`mpq = (x^p)(y^q)I(y, x) for each p, q in the corner patch`
1313
14-
The kernel used for the patch can be given through the `kernel` argument.
14+
The kernel used for the patch can be given through the `kernel` argument. The default kernel used is a gaussian kernel of size `5x5`.
1515
"""
1616
function corner_orientations{T<:Gray, K<:Real}(img::AbstractArray{T, 2}, corners::Keypoints, kernel::Array{K, 2})
1717
h, w = size(kernel)

src/freak.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
"""
2+
```
3+
freak_params = FREAK([pattern_scale = 22.0])
4+
```
5+
6+
| Argument | Type | Description |
7+
|----------|------|-------------|
8+
| `pattern_scale` | `Float64` | Scaling factor for the sampling window |
9+
"""
110
type FREAK{S, T, O} <: DescriptorParams
211
pattern_scale::Float64
312
pattern_table::Array{Array{S, 1}, 1}

src/orb.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
type ORB <: DescriptorParams
2-
num_keypoints::Int
3-
n_fast::Int
4-
threshold::Float64
5-
harris_factor::Float64
6-
downsample::Float64
7-
levels::Int
8-
sigma::Float64
9-
end
10-
111
"""
122
```
133
orb_params = ORB([num_keypoints = 500], [n_fast = 12], [threshold = 0.25], [harris_factor = 0.04], [downsample = 1.3], [levels = 8], [sigma = 1.2])
@@ -23,6 +13,16 @@ orb_params = ORB([num_keypoints = 500], [n_fast = 12], [threshold = 0.25], [harr
2313
| `levels` | `Int` | Number of levels in the gaussian pyramid. See [`gaussian_pyramid`] in Images.jl |
2414
| `sigma` | `Float64` | Used for gaussian smoothing in each level of the gaussian pyramid. See [`gaussian_pyramid`] in Images.jl |
2515
"""
16+
type ORB <: DescriptorParams
17+
num_keypoints::Int
18+
n_fast::Int
19+
threshold::Float64
20+
harris_factor::Float64
21+
downsample::Float64
22+
levels::Int
23+
sigma::Float64
24+
end
25+
2626
function ORB(; num_keypoints::Int = 500, n_fast::Int = 12, threshold::Float64 = 0.25, harris_factor::Float64 = 0.04, downsample::Real = 1.3, levels::Int = 8, sigma::Float64 = 1.2)
2727
ORB(num_keypoints, n_fast, threshold, harris_factor, downsample, levels, sigma)
2828
end

0 commit comments

Comments
 (0)