-
Notifications
You must be signed in to change notification settings - Fork 143
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
Adds Integral Image. Required for CENSURE in ImageFeatures #508
Conversation
f033201
to
caf0d96
Compare
Corrected Build error. |
function integral_image(img::AbstractArray) | ||
integral_img = convert(Array{UInt}, raw(img)) | ||
for i in 1:ndims(img) | ||
integral_img = cumsum(integral_img, i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If img
is a color image, then raw
will expand the color channel so it's the first dimension, and this will be an error.
I'd prefer to write it something like this:
integral_img = Array{accum(eltype(img))}(size(img))
sd = coords_spatial(img)
cumsum!(integral_img, img, sd[1])
for i = 2:length(sd)
cumsum!(integral_img, integral_img, sd[i])
end
integral_img
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could not find docs for the accum
method. What does that do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It basically picks an "accumulation type"; as you noticed, if the underlying type is U8
(or UInt8
), overflow will occur. This is an internal method; we could document it, of course.
tim@diva:~/.julia/v0.5/Images/src$ grep accum *
algorithms.jl: # When we are reducing along dim == 1, we can accumulate to a temporary
algorithms.jl: s = zero(accum(eltype(T)))
algorithms.jl:accum{T<:Integer}(::Type{T}) = Int
algorithms.jl:accum(::Type{Float32}) = Float32
algorithms.jl:accum{T<:Real}(::Type{T}) = Float64
We'd need to generalize it for colors, of course. Probably
accum{C<:Colorant}(::Type{C}) = base_colorant_type(C){accum(eltype(C))}
would suffice.
9cf2a60
to
3438860
Compare
I've made the changes. |
Thanks! |
No description provided.