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

Unable to use readme examples (except with ImageSegmentation dev'd). methoderror iterate(::Gray{Float64}) #79

Closed
anandijain opened this issue Sep 6, 2021 · 5 comments

Comments

@anandijain
Copy link

I'm trying to follow these docs https://juliaimages.org/stable/pkgs/segmentation/

I tried starting a temp environment with Pkg.activate(;temp=true) to ensure it wasn't just my current environment causing issues, but the following code fails. (FFTW is just because I'm on m1, I don't think it is related to my issue).

using Pkg
Pkg.add(url="https://github.com/giordano/FFTW_jll.jl")
Pkg.add(["ImageCore", "ImageSegmentation"])
using Images, ImageSegmentation, ImageFiltering
img = rand(Gray, 1000, 1000)
seeds = [(CartesianIndex(126,81),1), (CartesianIndex(93,255),2), (CartesianIndex(213,97),3)]
segments = seeded_region_growing(img, seeds)

julia> segments = seeded_region_growing(img, seeds)
ERROR: MethodError: no method matching iterate(::Gray{Float64})
  ...
Stacktrace:

After deving ImageSegmentation itself, I was able to run those last 4 lines and get seeded_region_growing to work.

I vaguely suspect it has something to do with ColorVectorSpace, as this was the only thing that stuck out as having a lower version, but having a tough time figuring out whats wrong.

@johnnychen94
Copy link
Member

A working PR is #72

@timholy
Copy link
Member

timholy commented Sep 6, 2021

If you were using released versions of all packages, it should have worked. If you can replicate the problem, please post the output of Pkg.status() and possibly your Project.toml and Manifest.toml in a gist.

@timholy
Copy link
Member

timholy commented Sep 6, 2021

While it should work with released versions of packages, #80 also makes it possible to use the latest ColorVectorSpace/ImageCore etc. Hence I'll close this.

@timholy timholy closed this as completed Sep 6, 2021
@kforner
Copy link

kforner commented Oct 14, 2021

same error, using a fresh install of julia 1.6.3.
Just followed the doc:

pkg> add Images ImageSegmentation TestImages

using ImageSegmentation, TestImages
img = testimage("camera")
seg = fast_scanning(img, 0.1)  # threshold = 0.1

julia> seg = fast_scanning(img, 0.1)  # threshold = 0.1
ERROR: MethodError: no method matching iterate(::Gray{Float64})
Closest candidates are:
  iterate(::Union{LinRange, StepRangeLen}) at range.jl:664
  iterate(::Union{LinRange, StepRangeLen}, ::Int64) at range.jl:664
  iterate(::T) where T<:Union{Base.KeySet{var"#s77", var"#s76"} where {var"#s77", var"#s76"<:Dict}, Base.ValueIterator{var"#s75"} where var"#s75"<:Dict} at dict.jl:693
  ...
Stacktrace:
  [1] _foldl_impl(op::Base.MappingRF{typeof(abs2), Base.BottomRF{typeof(Base.add_sum)}}, init::Base._InitialValue, itr::Gray{Float64})
    @ Base ./reduce.jl:56
  [2] foldl_impl(op::Base.MappingRF{typeof(abs2), Base.BottomRF{typeof(Base.add_sum)}}, nt::Base._InitialValue, itr::Gray{Float64})
    @ Base ./reduce.jl:48
  [3] mapfoldl_impl(f::typeof(abs2), op::typeof(Base.add_sum), nt::Base._InitialValue, itr::Gray{Float64})
    @ Base ./reduce.jl:44
  [4] mapfoldl(f::Function, op::Function, itr::Gray{Float64}; init::Base._InitialValue)
    @ Base ./reduce.jl:160
  [5] mapfoldl(f::Function, op::Function, itr::Gray{Float64})
    @ Base ./reduce.jl:160
  [6] mapreduce(f::Function, op::Function, itr::Gray{Float64}; kw::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base ./reduce.jl:287
  [7] mapreduce(f::Function, op::Function, itr::Gray{Float64})
    @ Base ./reduce.jl:287
  [8] sum(f::Function, a::Gray{Float64}; kw::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base ./reduce.jl:501
  [9] sum(f::Function, a::Gray{Float64})
    @ Base ./reduce.jl:501
 [10] default_diff_fn(c1::Gray{Float64}, c2::Gray{N0f8})
    @ ImageSegmentation ~/.julia/packages/ImageSegmentation/MX8ga/src/region_growing.jl:2
 [11] fast_scanning(img::Matrix{Gray{N0f8}}, threshold::Float64, diff_fn::typeof(ImageSegmentation.default_diff_fn))
    @ ImageSegmentation ~/.julia/packages/ImageSegmentation/MX8ga/src/fast_scanning.jl:92
 [12] fast_scanning(img::Matrix{Gray{N0f8}}, threshold::Float64)
    @ ImageSegmentation ~/.julia/packages/ImageSegmentation/MX8ga/src/fast_scanning.jl:66
 [13] top-level scope
    @ REPL[31]:1

@johnnychen94
Copy link
Member

johnnychen94 commented Oct 14, 2021

Sorry for the inconvenience, we're still during the transition to ImageCore v0.9 stage. JuliaImages/Images.jl#971

To follow the example, currently, you have to remove Images first (or activating a new environment) so that you can get the latest ImageSegmentation v1.6.0 version installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants