Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sampled_intensities eltype issue in create_descriptor for FREAK and BRISK #107

Closed
mathieu17g opened this issue Jul 30, 2023 · 0 comments · Fixed by #108
Closed

sampled_intensities eltype issue in create_descriptor for FREAK and BRISK #107

mathieu17g opened this issue Jul 30, 2023 · 0 comments · Fixed by #108

Comments

@mathieu17g
Copy link
Contributor

In the create_descriptor functions for FREAK and BRISK, the sampled_intensities array is declared with the same type of the input image, but it should be declared with the same type as the integral image of the input image.

For some images I'm working with, it leads to the following error:

julia> using Images, ImageFeatures
       img = load("test_image.png")
       img1 = Gray.(img)::Matrix{Gray{N0f8}} 
       feats_1 = Features(fastcorners(img1, 20, 0.5))
       brisk_params = BRISK()
       desc_1, ret_feats_1 = create_descriptor(img1, feats_1, brisk_params)
       nothing
ERROR: ArgumentError: element type N0f8 is an 8-bit type representing 256 values from 0.0 to 1.0,
  but the values (1.0034722f0,) do not lie within this range.
  See the READMEs for FixedPointNumbers and ColorTypes for more information.
Stacktrace:
  [1] throw_colorerror_(#unused#::Type{N0f8}, values::Tuple{Float32})
    @ ColorTypes ~/.julia/packages/ColorTypes/1dGw6/src/types.jl:686
  [2] throw_colorerror(#unused#::Type{Gray{N0f8}}, values::Tuple{Float32})
    @ ColorTypes ~/.julia/packages/ColorTypes/1dGw6/src/types.jl:736
  [3] checkval
    @ ~/.julia/packages/ColorTypes/1dGw6/src/types.jl:648 [inlined]
  [4] Gray
    @ ~/.julia/packages/ColorTypes/1dGw6/src/types.jl:359 [inlined]
  [5] _convert
    @ ~/.julia/packages/ColorTypes/1dGw6/src/conversions.jl:96 [inlined]
  [6] cconvert
    @ ~/.julia/packages/ColorTypes/1dGw6/src/conversions.jl:76 [inlined]
  [7] convert
    @ ~/.julia/packages/ColorTypes/1dGw6/src/conversions.jl:73 [inlined]
  [8] push!
    @ ./array.jl:1060 [inlined]
  [9] create_descriptor(img::Matrix{Gray{N0f8}}, features::Vector{Feature}, params::BRISK)
    @ ImageFeatures ~/.julia/dev/ImageFeatures/src/brisk.jl:95
 [10] top-level scope
    @ REPL[1]:6

Here is the test image, to reproduce the issue if needed:
test_image

The fix could be to replace

sampled_intensities = T[]

by

        sampled_intensities = eltype(int_img)[]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant