I thought I'd give 0.4 a spin to try out the new garbage collector.

On my current codebase developed with 0.3 I ran into several warnings 
(*float32() 
should now be Float32()* - that sort of thing)

And then this error:






*ERROR: LoadError: LoadError: LoadError: LoadError: LoadError: MethodError: 
`convert` has no method matching convert(::Type{Img.ImgHSV}, 
::UTF8String)This may have arisen from a call to the constructor 
Img.ImgHSV(...),since type constructors fall back to convert 
methods.Closest candidates are:  convert{T}(::Type{T}, ::T)*
After poking around New Language Features and the list here a bit it seems 
that there are changes to how overloaded constructors work.

In my case I've got:

type ImgHSV
  name::ASCIIString
  data::Array{HSV{Float32},2}  
  #data::Array{IntHSV,2}  
  height::Int64
  wid::Int64
  h_mean::Float32
  s_mean::Float32
  v_mean::Float32
  h_std::Float32
  s_std::Float32
  v_std::Float32
end

# Given a filename of an image file, construct an ImgHSV
function ImgHSV(fn::ASCIIString)
  name,ext = splitext(basename(fn))
  source_img_hsv = Images.data(convert(Image{HSV{Float64}},imread(fn)))
  #scale all the values up from (0->1) to (0->255)
  source_img_scaled = map(x-> HSV( ((x.h/360)*255),(x.s*255),(x.v*255)),
                          source_img_hsv)
  img_ht  = size(source_img_hsv,2)
  img_wid = size(source_img_hsv,1)
  h_mean = (mean(map(x-> x.h,source_img_hsv)/360)*255)
  s_mean = (mean(map(x-> x.s,source_img_hsv))*255)
  v_mean = (mean(map(x-> x.v,source_img_hsv))*255)
  h_std  = (std(map(x-> x.h,source_img_hsv)/360)*255)
  s_std  = (std(map(x-> x.s,source_img_hsv))*255)
  v_std  = (std(map(x-> x.v,source_img_hsv))*255)
  ImgHSV(
    name,
    float32(source_img_scaled),
    img_ht,
    img_wid,
    h_mean,
    s_mean,
    v_mean,
    h_std,
    s_std,
    v_std
  )
end

Should I rename this function to something like buildImgHSV so it's not 
actually a constructor and *convert* doesn't enter the picture?

Phil

Reply via email to