Skip to content

Commit 35212ca

Browse files
Fix deprecations
1 parent d3a7664 commit 35212ca

File tree

10 files changed

+65
-65
lines changed

10 files changed

+65
-65
lines changed

src/brief.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ brief_params = BRIEF([size = 128], [window = 9], [sigma = 2 ^ 0.5], [sampling_ty
1212
| **seed** | Int | Random seed used for generating the sampling pairs. For matching two descriptors, the seed used to build both should be same. |
1313
1414
"""
15-
type BRIEF{F} <: Params
15+
mutable struct BRIEF{F} <: Params
1616
size::Int
1717
window::Int
1818
sigma::Float64
@@ -147,7 +147,7 @@ function center_sample(size::Int, window::Int, seed::Int)
147147
zeros(CartesianIndex{2}, size), sample
148148
end
149149

150-
function create_descriptor{T<:Gray}(img::AbstractArray{T, 2}, keypoints::Keypoints, params::BRIEF)
150+
function create_descriptor(img::AbstractArray{T, 2}, keypoints::Keypoints, params::BRIEF) where T<:Gray
151151
factkernel = KernelFactors.IIRGaussian([params.sigma, params.sigma])
152152
img_smoothed = imfilter(Float64, img, factkernel, NA())
153153
sample_one, sample_two = params.sampling_type(params.size, params.window, params.seed)

src/brisk.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ brisk_params = BRISK([pattern_scale = 1.0])
77
|----------|------|-------------|
88
| `pattern_scale` | `Float64` | Scaling factor for the sampling window |
99
"""
10-
type BRISK <: Params
10+
mutable struct BRISK <: Params
1111
threshold::Float64
1212
octaves::Int
1313
pattern_scale::Float64
@@ -41,8 +41,8 @@ function BRISK(; threshold::Float64 = 0.25, octaves::Int = 4, pattern_scale = 1.
4141
BRISK(threshold, octaves, pattern_scale, pattern_table, smoothing_table, orientation_weights, short_pairs, long_pairs)
4242
end
4343

44-
function _brisk_orientation{T<:Gray}(int_img::AbstractArray{T, 2}, keypoint::Keypoint, pattern::Array{SamplePair},
45-
orientation_weights::Array{OrientationWeights}, sigmas::Array{Float16}, long_pairs::Array{OrientationPair})
44+
function _brisk_orientation(int_img::AbstractArray{T, 2}, keypoint::Keypoint, pattern::Array{SamplePair},
45+
orientation_weights::Array{OrientationWeights}, sigmas::Array{Float16}, long_pairs::Array{OrientationPair}) where T<:Gray
4646
direction_sum_y = 0.0
4747
direction_sum_x = 0.0
4848
for (i, o) in enumerate(long_pairs)
@@ -79,7 +79,7 @@ function _brisk_tables(pattern_scale::Float64)
7979
pattern_table, smoothing_table
8080
end
8181

82-
function create_descriptor{T<:Gray}(img::AbstractArray{T, 2}, features::Features, params::BRISK)
82+
function create_descriptor(img::AbstractArray{T, 2}, features::Features, params::BRISK) where T<:Gray
8383
int_img = integral_image(img)
8484
descriptors = BitArray{1}[]
8585
ret_features = Feature[]

src/core.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@compat abstract type Params end
1+
abstract type Params end
22

33
"""
44
```
@@ -27,7 +27,7 @@ feature = Feature(keypoint, orientation = 0.0, scale = 0.0)
2727
2828
The `Feature` type has the keypoint, its orientation and its scale.
2929
"""
30-
immutable Feature
30+
struct Feature
3131
keypoint::Keypoint
3232
orientation::Float64
3333
scale::Float64

src/corner.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The intensity centroid can be calculated as `C = (m01/m00, m10/m00)` where mpq i
1313
1414
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
"""
16-
function corner_orientations{T<:Gray, K<:Real}(img::AbstractArray{T, 2}, corners::Keypoints, kernel::Array{K, 2})
16+
function corner_orientations(img::AbstractArray{T, 2}, corners::Keypoints, kernel::Array{K, 2}) where {T<:Gray, K<:Real}
1717
h, w = size(kernel)
1818
pre_y = ceil(Int, (h - 1) / 2)
1919
pre_x = ceil(Int, (w - 1) / 2)
@@ -38,9 +38,9 @@ function corner_orientations{T<:Gray, K<:Real}(img::AbstractArray{T, 2}, corners
3838
orientations
3939
end
4040

41-
corner_orientations{T, K<:Real}(img::AbstractArray{T, 2}, corners::Keypoints, kernel::Array{K, 2}) = corner_orientations(convert(Array{Gray}, img), corners, kernel)
41+
corner_orientations(img::AbstractArray{T, 2}, corners::Keypoints, kernel::Array{K, 2}) where {T, K<:Real} = corner_orientations(convert(Array{Gray}, img), corners, kernel)
4242

43-
function corner_orientations{K<:Real}(img::AbstractArray, kernel::Array{K, 2})
43+
function corner_orientations(img::AbstractArray, kernel::Array{K, 2}) where K<:Real
4444
corners = imcorner(img)
4545
corner_indexes = Keypoints(corners)
4646
corner_orientations(img, corner_indexes, kernel)

src/freak.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ freak_params = FREAK([pattern_scale = 22.0])
77
|----------|------|-------------|
88
| **pattern_scale** | Float64 | Scaling factor for the sampling window |
99
"""
10-
type FREAK <: Params
10+
mutable struct FREAK <: Params
1111
pattern_scale::Float64
1212
pattern_table::Vector{Vector{SamplePair}}
1313
smoothing_table::Vector{Vector{Float16}}
@@ -28,7 +28,7 @@ function FREAK(; pattern_scale::Float64 = 22.0)
2828
FREAK(pattern_scale, pattern_table, smoothing_table, orientation_weights)
2929
end
3030

31-
function _freak_mean_intensity{T<:Gray}(int_img::AbstractArray{T, 2}, keypoint::Keypoint, offset::SamplePair, sigma::Float16)
31+
function _freak_mean_intensity(int_img::AbstractArray{T, 2}, keypoint::Keypoint, offset::SamplePair, sigma::Float16) where T<:Gray
3232
y = keypoint[1] + offset[1]
3333
x = keypoint[2] + offset[2]
3434
if sigma < 0.5
@@ -42,8 +42,8 @@ function _freak_mean_intensity{T<:Gray}(int_img::AbstractArray{T, 2}, keypoint::
4242
intensity / ((xst - xs + 1) * (yst - ys + 1))
4343
end
4444

45-
function _freak_orientation{T<:Gray}(int_img::AbstractArray{T, 2}, keypoint::Keypoint, pattern::Array{SamplePair},
46-
orientation_weights::Array{OrientationWeights}, sigmas::Array{Float16})
45+
function _freak_orientation(int_img::AbstractArray{T, 2}, keypoint::Keypoint, pattern::Array{SamplePair},
46+
orientation_weights::Array{OrientationWeights}, sigmas::Array{Float16}) where T<:Gray
4747
direction_sum_y = 0.0
4848
direction_sum_x = 0.0
4949
for (i, o) in enumerate(freak_orientation_sampling_pattern)
@@ -81,7 +81,7 @@ function _freak_tables(pattern_scale::Float64)
8181
pattern_table, smoothing_table
8282
end
8383

84-
function create_descriptor{T<:Gray}(img::AbstractArray{T, 2}, keypoints::Keypoints, params::FREAK)
84+
function create_descriptor(img::AbstractArray{T, 2}, keypoints::Keypoints, params::FREAK) where T<:Gray
8585
int_img = integral_image(img)
8686
descriptors = BitArray{1}[]
8787
ret_keypoints = Keypoint[]

src/glcm.jl

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
function glcm{T<:Real}(img::AbstractArray{T, 2}, distance::Integer, angle::Real, mat_size::Integer = 16)
1+
function glcm(img::AbstractArray{T, 2}, distance::Integer, angle::Real, mat_size::Integer = 16) where T<:Real
22
max_img = maximum(img)
33
img_rescaled = map(i -> max(1, Int(ceil(i * mat_size / max_img))), img)
44
_glcm(img_rescaled, distance, angle, mat_size)
55
end
66

7-
function glcm{T<:Real, A<:Real}(img::AbstractArray{T, 2}, distances::Array{Int, 1}, angles::Array{A, 1}, mat_size::Integer = 16)
7+
function glcm(img::AbstractArray{T, 2}, distances::Array{Int, 1}, angles::Array{A, 1}, mat_size::Integer = 16) where {T<:Real, A<:Real}
88
max_img = maximum(img)
99
img_rescaled = map(i -> max(1, Int(ceil(i * mat_size / max_img))), img)
1010
glcm_matrices = [_glcm(img_rescaled, d, a, mat_size) for d in distances, a in angles]
1111
glcm_matrices
1212
end
1313

14-
function glcm{T<:Colorant}(img::AbstractArray{T, 2}, distance::Integer, angle::Real, mat_size::Integer = 16)
14+
function glcm(img::AbstractArray{T, 2}, distance::Integer, angle::Real, mat_size::Integer = 16) where T<:Colorant
1515
img_rescaled = map(i -> max(1, Int(ceil((reinterpret(gray(convert(Gray{N0f8}, i)))) * mat_size / 256))), img)
1616
_glcm(img_rescaled, distance, angle, mat_size)
1717
end
1818

19-
function glcm{T<:Colorant, A<:Real}(img::AbstractArray{T, 2}, distances::Array{Int, 1}, angles::Array{A, 1}, mat_size::Integer = 16)
19+
function glcm(img::AbstractArray{T, 2}, distances::Array{Int, 1}, angles::Array{A, 1}, mat_size::Integer = 16) where {T<:Colorant, A<:Real}
2020
img_rescaled = map(i -> max(1, Int(ceil((reinterpret(gray(convert(Gray{N0f8}, i)))) * mat_size / 256))), img)
2121
glcm_matrices = [_glcm(img_rescaled, d, a, mat_size) for d in distances, a in angles]
2222
glcm_matrices
2323
end
2424

25-
glcm{T<:Union{Colorant, Real}, A<:Real}(img::AbstractArray{T, 2}, distances::Int, angles::Array{A, 1}, mat_size::Integer = 16) = glcm(img, [distances], angles, mat_size)
26-
glcm{T<:Union{Colorant, Real}}(img::AbstractArray{T, 2}, distances::Array{Int, 1}, angles::Real, mat_size::Integer = 16) = glcm(img, distances, [angles], mat_size)
25+
glcm(img::AbstractArray{T, 2}, distances::Int, angles::Array{A, 1}, mat_size::Integer = 16) where {T<:Union{Colorant, Real}, A<:Real} = glcm(img, [distances], angles, mat_size)
26+
glcm(img::AbstractArray{T, 2}, distances::Array{Int, 1}, angles::Real, mat_size::Integer = 16) where {T<:Union{Colorant, Real}} = glcm(img, distances, [angles], mat_size)
2727

28-
function _glcm{T}(img::AbstractArray{T, 2}, distance::Integer, angle::Number, mat_size::Integer)
28+
function _glcm(img::AbstractArray{T, 2}, distance::Integer, angle::Number, mat_size::Integer) where T
2929
co_oc_matrix = zeros(Int, mat_size, mat_size)
3030
sin_angle = sin(angle)
3131
cos_angle = cos(angle)
@@ -70,7 +70,7 @@ function glcm_norm(img::AbstractArray, distances, angles, mat_size)
7070
co_oc_matrices_norm
7171
end
7272

73-
function glcm_prop{T<:Real}(gmat::Array{T, 2}, window_height::Integer, window_width::Integer, property::Function)
73+
function glcm_prop(gmat::Array{T, 2}, window_height::Integer, window_width::Integer, property::Function) where T<:Real
7474
k_h = Int(floor(window_height / 2))
7575
k_w = Int(floor(window_width / 2))
7676
glcm_size = size(gmat)
@@ -82,59 +82,59 @@ function glcm_prop{T<:Real}(gmat::Array{T, 2}, window_height::Integer, window_wi
8282
prop_mat
8383
end
8484

85-
glcm_prop{T<:Real}(gmat::Array{T, 2}, window_size::Integer, property::Function) = glcm_prop(gmat, window_size, window_size, property)
85+
glcm_prop(gmat::Array{T, 2}, window_size::Integer, property::Function) where {T<:Real} = glcm_prop(gmat, window_size, window_size, property)
8686

87-
function glcm_prop{T<:Real}(gmat::Array{T, 2}, property::Function)
87+
function glcm_prop(gmat::Array{T, 2}, property::Function) where T<:Real
8888
property(gmat)
8989
end
9090

91-
function contrast{T<:Real}(glcm_window::Array{T, 2})
91+
function contrast(glcm_window::Array{T, 2}) where T<:Real
9292
sum([(id[1] - id[2]) ^ 2 * glcm_window[id] for id in CartesianRange(size(glcm_window))])
9393
end
9494

95-
function dissimilarity{T<:Real}(glcm_window::Array{T, 2})
95+
function dissimilarity(glcm_window::Array{T, 2}) where T<:Real
9696
sum([glcm_window[id] * abs(id[1] - id[2]) for id in CartesianRange(size(glcm_window))])
9797
end
9898

99-
function glcm_entropy{T<:Real}(glcm_window::Array{T, 2})
99+
function glcm_entropy(glcm_window::Array{T, 2}) where T<:Real
100100
-sum(map(i -> i * log(i), glcm_window))
101101
end
102102

103-
function ASM{T<:Real}(glcm_window::Array{T, 2})
103+
function ASM(glcm_window::Array{T, 2}) where T<:Real
104104
sum(map(i -> i ^ 2, glcm_window))
105105
end
106106

107-
function IDM{T<:Real}(glcm_window::Array{T, 2})
107+
function IDM(glcm_window::Array{T, 2}) where T<:Real
108108
sum([glcm_window[id] / (1 + (id[1] - id[2]) ^ 2) for id in CartesianRange(size(glcm_window))])
109109
end
110110

111-
function glcm_mean_ref{T<:Real}(glcm_window::Array{T, 2})
111+
function glcm_mean_ref(glcm_window::Array{T, 2}) where T<:Real
112112
sumref = sum(glcm_window, 2)
113113
meanref = sum([id * sumref[id] for id = 1:size(glcm_window)[1]])
114114
meanref
115115
end
116116

117-
function glcm_mean_neighbour{T<:Real}(glcm_window::Array{T, 2})
117+
function glcm_mean_neighbour(glcm_window::Array{T, 2}) where T<:Real
118118
sumneighbour = sum(glcm_window, 1)
119119
meanneighbour = sum([id * sumneighbour[id] for id = 1:size(glcm_window)[2]])
120120
meanneighbour
121121
end
122122

123-
function glcm_var_ref{T<:Real}(glcm_window::Array{T, 2})
123+
function glcm_var_ref(glcm_window::Array{T, 2}) where T<:Real
124124
mean_ref = glcm_mean_ref(glcm_window)
125125
sumref = sum(glcm_window, 2)
126126
var_ref = sum([((id - mean_ref) ^ 2) * sumref[id] for id = 1:size(glcm_window)[1]])
127127
var_ref ^ 0.5
128128
end
129129

130-
function glcm_var_neighbour{T<:Real}(glcm_window::Array{T, 2})
130+
function glcm_var_neighbour(glcm_window::Array{T, 2}) where T<:Real
131131
mean_neighbour = glcm_mean_neighbour(glcm_window)
132132
sumneighbour = sum(glcm_window, 1)
133133
var_neighbour = sum([((id - mean_neighbour) ^ 2) * sumneighbour[id] for id = 1:size(glcm_window)[2]])
134134
var_neighbour ^ 0.5
135135
end
136136

137-
function correlation{T<:Real}(glcm_window::Array{T, 2})
137+
function correlation(glcm_window::Array{T, 2}) where T<:Real
138138
mean_ref = glcm_mean_ref(glcm_window)
139139
var_ref = glcm_var_ref(glcm_window)
140140
mean_neighbour = glcm_mean_neighbour(glcm_window)
@@ -145,10 +145,10 @@ function correlation{T<:Real}(glcm_window::Array{T, 2})
145145
sum([glcm_window[i, j] * (i - mean_ref) * (j - mean_neighbour) for i = 1:size(glcm_window)[1], j = 1:size(glcm_window)[2]]) / (var_ref * var_neighbour)
146146
end
147147

148-
function max_prob{T<:Real}(glcm_window::Array{T, 2})
148+
function max_prob(glcm_window::Array{T, 2}) where T<:Real
149149
maxfinite(glcm_window)
150150
end
151151

152-
function energy{T<:Real}(glcm_window::Array{T, 2})
152+
function energy(glcm_window::Array{T, 2}) where T<:Real
153153
ASM(glcm_window) ^ 0.5
154154
end

src/hog.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Parameters:
1212
- block_stride = stride of blocks. Controls how much adjacent blocks overlap.
1313
- norm_method = block normalization method. Options: L2-norm, L2-hys, L1-norm, L2-sqrt.
1414
"""
15-
type HOG <: Params
15+
mutable struct HOG <: Params
1616
orientations::Int
1717
cell_size::Int
1818
block_size::Int
@@ -24,7 +24,7 @@ function HOG(; orientations::Int = 9, cell_size::Int = 8, block_size::Int = 2, b
2424
HOG(orientations, cell_size, block_size, block_stride, norm_method)
2525
end
2626

27-
function create_descriptor{CT<:Images.NumberLike}(img::AbstractArray{CT, 2}, params::HOG)
27+
function create_descriptor(img::AbstractArray{CT, 2}, params::HOG) where CT<:Images.NumberLike
2828
#compute gradient
2929
gx = imfilter(img, centered([-1 0 1]))
3030
gy = imfilter(img, centered([-1 0 1]'))
@@ -34,7 +34,7 @@ function create_descriptor{CT<:Images.NumberLike}(img::AbstractArray{CT, 2}, par
3434
create_hog_descriptor(mag, phase, params)
3535
end
3636

37-
function create_descriptor{CT<:Images.Color{T, N} where T where N}(img::AbstractArray{CT, 2}, params::HOG)
37+
function create_descriptor(img::AbstractArray{CT, 2}, params::HOG) where CT<:Images.Color{T, N} where T where N
3838
#for color images, compute seperate gradient for each color channel and take one with largest norm as pixel's gradient vector
3939
rows, cols = size(img)
4040
gx = channelview(imfilter(img, centered([-1 0 1])))
@@ -56,7 +56,7 @@ function create_descriptor{CT<:Images.Color{T, N} where T where N}(img::Abstract
5656
create_hog_descriptor(max_mag, max_phase, params)
5757
end
5858

59-
function create_hog_descriptor{T<:Images.NumberLike}(mag::AbstractArray{T, 2}, phase::AbstractArray{T, 2}, params::HOG)
59+
function create_hog_descriptor(mag::AbstractArray{T, 2}, phase::AbstractArray{T, 2}, params::HOG) where T<:Images.NumberLike
6060
orientations = params.orientations
6161
cell_size = params.cell_size
6262
block_size = params.block_size

src/houghtransform.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ julia> lines = hough_transform_standard(img_edges, 1, linspace(0,π,30), 40, 5)
3737
```
3838
"""
3939

40-
function hough_transform_standard{T<:Union{Bool,Gray{Bool}}}(
41-
img::AbstractArray{T,2},
42-
ρ::Real, θ::Range,
43-
threshold::Integer, linesMax::Integer)
40+
function hough_transform_standard(
41+
img::AbstractArray{T,2},
42+
ρ::Real, θ::Range,
43+
threshold::Integer, linesMax::Integer) where T<:Union{Bool,Gray{Bool}}
4444

4545

4646
#function to compute local maximum lines with values > threshold and return a vector containing them
47-
function findlocalmaxima!{T<:Integer}(validLines::AbstractVector{CartesianIndex{2}}, accumulator_matrix::Array{Int,2}, threshold::T)
47+
function findlocalmaxima!(validLines::AbstractVector{CartesianIndex{2}}, accumulator_matrix::Array{Int,2}, threshold::T) where T<:Integer
4848
for val in CartesianRange(size(accumulator_matrix))
4949
if accumulator_matrix[val] > threshold &&
5050
accumulator_matrix[val] > accumulator_matrix[val[1],val[2] - 1] &&
@@ -134,10 +134,10 @@ centers, radii=hough_circle_gradient(img_edges, img_phase, 1, 60, 60, 3:50)
134134
```
135135
"""
136136

137-
function hough_circle_gradient{T<:Number}(
137+
function hough_circle_gradient(
138138
img_edges::AbstractArray{Bool,2}, img_phase::AbstractArray{T,2},
139139
scale::Number, min_dist::Number,
140-
vote_thres::Number, radii::AbstractVector{Int})
140+
vote_thres::Number, radii::AbstractVector{Int}) where T<:Number
141141

142142
rows,cols=size(img_edges)
143143

0 commit comments

Comments
 (0)