Skip to content

prune_segments - ERROR: MethodError: no method matching add_vertices!(::SimpleWeightedGraph{Int64, Float64}, ::Int64) #86

@chris-revell

Description

@chris-revell

I'm trying to run some examples from the documentation, such as the following:

using ImageSegmentation, TestImages
img = testimage("camera")
seg = fast_scanning(img, 0.1)
seg = prune_segments(seg, i->(segment_pixel_count(seg,i)<50), (i,j)->(-segment_pixel_count(seg,j)))

Unfortunately this returns the following error:

ERROR: MethodError: no method matching add_vertices!(::SimpleWeightedGraphs.SimpleWeightedGraph{Int64, Float64}, ::Int64)
Closest candidates are:
  add_vertices!(::LightGraphs.AbstractGraph, ::Integer) at /Users/christopher/.julia/packages/LightGraphs/IgJif/src/core.jl:45
Stacktrace:
 [1] region_adjacency_graph(s::SegmentedImage{Matrix{Int64}, ColorTypes.Gray{Float64}}, weight_fn::ImageSegmentation.var"#12#13")
   @ ImageSegmentation ~/.julia/packages/ImageSegmentation/MX8ga/src/core.jl:109
 [2] prune_segments(s::SegmentedImage{Matrix{Int64}, ColorTypes.Gray{Float64}}, is_rem::var"#1#3", diff_fn::var"#2#4")
   @ ImageSegmentation ~/.julia/packages/ImageSegmentation/MX8ga/src/core.jl:221
 [3] top-level scope
   @ REPL[4]:1

Any ideas as to what might be going on here?

Julia version 1.6.4 on macOS 12.0.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions