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

Can't find iterate(::ColorTypes.RGB{Float64}) #1019

Open
drdozer opened this issue Feb 7, 2023 · 2 comments
Open

Can't find iterate(::ColorTypes.RGB{Float64}) #1019

drdozer opened this issue Feb 7, 2023 · 2 comments

Comments

@drdozer
Copy link

drdozer commented Feb 7, 2023

I am trying to load in some jpeg images (from a phone) and segment out the background. My code looks like this:

function segment(img)
	dims = size(img)
	half(x) = floor(Int, x / 2)
	mid = half.(dims)
	seeds = [(CartesianIndex(1, 1), 1), (CartesianIndex(mid...), 2)]
	segments = seeded_region_growing(img, seeds)

	segments
end

The images are loaded with load. I can view the images in pluto, so I know the data is good. The type of the image is Matrix{RGB{N0f8}} (alias for Array{RGB{Normed{UInt8, 8}}, 2}).

When I call seeded_region_growing I get this error:

MethodError: no method matching iterate(::ColorTypes.RGB{Float64})

Closest candidates are:

iterate(!Matched::Union{LinRange, StepRangeLen}) at range.jl:872

iterate(!Matched::Union{LinRange, StepRangeLen}, !Matched::Integer) at range.jl:872

iterate(!Matched::T) where T<:Union{Base.KeySet{<:Any, <:Dict}, Base.ValueIterator{<:Dict}} at dict.jl:712

...
_foldl_impl(::Base.MappingRF{typeof(abs2), Base.BottomRF{typeof(Base.add_sum)}}, ::Base._InitialValue, ::ColorTypes.RGB{Float64})@reduce.jl:56
foldl_impl(::Base.MappingRF{typeof(abs2), Base.BottomRF{typeof(Base.add_sum)}}, ::Base._InitialValue, ::ColorTypes.RGB{Float64})@reduce.jl:48
mapfoldl_impl(::typeof(abs2), ::typeof(Base.add_sum), ::Base._InitialValue, ::ColorTypes.RGB{Float64})@reduce.jl:44
var"#mapfoldl#259"(::Base._InitialValue, ::typeof(mapfoldl), ::Function, ::Function, ::ColorTypes.RGB{Float64})@reduce.jl:170
mapfoldl(::Function, ::Function, ::ColorTypes.RGB{Float64})@reduce.jl:170
var"#mapreduce#263"(::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(mapreduce), ::Function, ::Function, ::ColorTypes.RGB{Float64})@reduce.jl:302
mapreduce(::Function, ::Function, ::ColorTypes.RGB{Float64})@reduce.jl:302
var"#sum#266"(::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(sum), ::Function, ::ColorTypes.RGB{Float64})@reduce.jl:528
sum(::Function, ::ColorTypes.RGB{Float64})@reduce.jl:528
default_diff_fn(::ColorTypes.RGB{Float64}, ::ColorTypes.RGB{FixedPointNumbers.N0f8})@region_growing.jl:2
seeded_region_growing(::Matrix{ColorTypes.RGB{FixedPointNumbers.N0f8}}, ::Vector{Tuple{CartesianIndex{2}, Int64}}, ::ImageSegmentation.var"#20#24"{CartesianIndex{2}}, ::typeof(ImageSegmentation.default_diff_fn))@region_growing.jl:125
seeded_region_growing(::Matrix{ColorTypes.RGB{FixedPointNumbers.N0f8}}, ::Vector{Tuple{CartesianIndex{2}, Int64}}, ::Tuple{Int64, Int64}, ::Function)@region_growing.jl:64
seeded_region_growing@region_growing.jl:57[inlined]
segment(::Matrix{ColorTypes.RGB{FixedPointNumbers.N0f8}})@[Other: 6](http://localhost:1234/edit?id=4ec61cfa-a6f2-11ed-37bd-254322b3a083#)
@Techmegh
Copy link

using Watershed

function seeded_region_growing(img, seeds)
labels = label_components(img)
for seed in seeds
labels[seed[1]] = seed[2]
end
return labels
end

@timholy
Copy link
Member

timholy commented Jul 23, 2023

I can't replicate this error. In case it's dependent on the specific image, it would help to have one that reproduces it.

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

3 participants