【问题标题】:Fuzzy C-means clustering in ImageSegmentation.jlImageSegmentation.jl 中的模糊 C 均值聚类
【发布时间】:2018-08-19 11:44:29
【问题描述】:

我正在尝试使用带有 ImageSegmentation.jl 的模糊 C 均值聚类来聚类图像的不同区域

using ImageSegmentation, Images
fl = load("flower.jpg")
fuzzy_fl = fuzzy_cmeans(fl,3,2)

它给出了这样的错误:

MethodError: no method matching fuzzy_cmeans(::Base.ReshapedArray{Float64,2,ImageCore.ChannelView{Float64,3,Array{ColorTypes.RGB4{Float64},2}},Tuple{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64},Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64}}})
Closest candidates are:
  fuzzy_cmeans(::Array{T<:Real,2}, ::Int64, ::Real; maxiter, tol, dist_metric, display) where T<:Real at /Users/asharma19/.julia/v0.6/Clustering/src/fuzzycmeans.jl:58
  fuzzy_cmeans(::AbstractArray{T<:ColorTypes.Colorant,N}, ::Any...; kwargs...) where {T<:ColorTypes.Colorant, N} at /Users/asharma19/.julia/v0.6/ImageSegmentation/src/clustering.jl:12

1) 我应该如何在这个函数中输入图像? 2)另外,如果它工作正常,因为该函数不返回 SegmentedImage 数组,那之后我应该如何显示分段/聚类图像?

【问题讨论】:

    标签: julia image-segmentation fuzzy-c-means


    【解决方案1】:

    代码对我来说很好用。在将其输入fuzzy_cmeans 函数之前,您可能正在对图像进行切片操作(例如视图、转置)。与您发布的代码示例不同。

    【讨论】:

    • 你在 Julia 0.6 中试过了吗?我无法让这个工作。如果您能帮助我解决第二个问题,那就太好了。
    • 同一张图片完美适用于其他算法。我也尝试过使用原始图像而没有任何操作。不知道怎么回事。
    【解决方案2】:

    函数fuzzy_cmeans 不接受Array{ColorTypes.RGB4{FixedPointNumbers.Normed{UInt8,8}},2}

    图片需要Array{ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}},2}才能在函数中输入。

    虽然它不应该发生,因为函数的参数类型是Colorant{T,N},它是AbstractRGB{T}的父级。

    图像通常是 RGB4(涉及一些填充),因此您需要在使用前对其进行转换。 (可以使用julia的convert函数)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-05
      • 2011-11-29
      • 2014-07-02
      • 2016-04-22
      • 1970-01-01
      • 2011-12-08
      • 2012-07-17
      相关资源
      最近更新 更多