Skip to content

Commit

Permalink
Change sampled_intensities eltype in create_descriptor for FREA…
Browse files Browse the repository at this point in the history
…K and BRISK (#108)
  • Loading branch information
mathieu17g authored Aug 11, 2023
1 parent 5b61fd2 commit 82817bf
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/brisk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function create_descriptor(img::AbstractArray{T, 2}, features::Features, params:
keypoint = Keypoint(feature)
checkbounds(Bool, img, keypoint - lim) && checkbounds(Bool, img, keypoint + lim) || continue
orientation = _brisk_orientation(int_img, keypoint, params.pattern_table[1], params.orientation_weights, params.smoothing_table[1], params.long_pairs)
sampled_intensities = T[]
sampled_intensities = eltype(int_img)[]
for (i, p) in enumerate(params.pattern_table[orientation])
push!(sampled_intensities, ImageFeatures._freak_mean_intensity(int_img, keypoint, p, params.smoothing_table[orientation][i]))
end
Expand Down
2 changes: 1 addition & 1 deletion src/freak.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function create_descriptor(img::AbstractArray{T, 2}, keypoints::Keypoints, param
for k in keypoints
checkbounds(Bool, img, k - lim) && checkbounds(Bool, img, k + lim) || continue
orientation = _freak_orientation(int_img, k, params.pattern_table[1], params.orientation_weights, params.smoothing_table[1])
sampled_intensities = T[]
sampled_intensities = eltype(int_img)[]
for (i, p) in enumerate(params.pattern_table[orientation])
push!(sampled_intensities, _freak_mean_intensity(int_img, k, p, params.smoothing_table[orientation][i]))
end
Expand Down
8 changes: 8 additions & 0 deletions test/brisk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,11 @@ end
reverse_keypoints_1 = [_reverserotate(m[1], pi / 4, (256, 256)) + CartesianIndex(10, 20) for m in matches]
@test all(isapprox(rk[1], m[2][1], atol = 4) && isapprox(rk[2], m[2][2], atol = 4) for (rk, m) in zip(reverse_keypoints_1, matches))
end

@testset "Testing descriptor creation with an image leading to sampled intensities > 1.0" begin
img = Gray.(testimage("autumn_leaves"))
# Number of contiguous pixels parameter in fastcorner needs to be low, to yield enough corners to hit a sample intensity > 1
feats = Features(fastcorners(img, 5, 0.3))
brisk_params = BRISK()
@test_nowarn create_descriptor(img, feats, brisk_params)
end
8 changes: 8 additions & 0 deletions test/freak.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,11 @@ end
reverse_keypoints_1 = [_reverserotate(m[1], pi / 4, (256, 256)) + CartesianIndex(10, 20) for m in matches]
@test isapprox(sum(isapprox(rk[1], m[2][1], atol = 4) && isapprox(rk[2], m[2][2], atol = 4) for (rk, m) in zip(reverse_keypoints_1, matches)), length(matches), atol = 2)
end

@testset "Testing descriptor creation with an image leading to sampled intensities > 1.0" begin
img = Gray.(testimage("autumn_leaves"))
# Number of contiguous pixels parametre in fastcorner needs to be low, to yield enough corners to hit a sample intensity > 1
keypoints = Keypoints(fastcorners(img, 5, 0.3))
freak_params = FREAK()
@test_nowarn create_descriptor(img, keypoints, freak_params)
end

0 comments on commit 82817bf

Please sign in to comment.