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

Adds Integral Image. Required for CENSURE in ImageFeatures #508

Merged
merged 3 commits into from
Jul 11, 2016

Conversation

mronian
Copy link
Contributor

@mronian mronian commented Jul 2, 2016

No description provided.

@mronian
Copy link
Contributor Author

mronian commented Jul 2, 2016

Corrected Build error.

@coveralls
Copy link

coveralls commented Jul 2, 2016

Coverage Status

Coverage decreased (-0.1%) to 74.678% when pulling caf0d96 on mronian:addsintegralimage into 90a7ea5 on timholy:master.

function integral_image(img::AbstractArray)
integral_img = convert(Array{UInt}, raw(img))
for i in 1:ndims(img)
integral_img = cumsum(integral_img, i)
Copy link
Member

@timholy timholy Jul 9, 2016

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

Copy link
Contributor Author

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?

Copy link
Member

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.

@coveralls
Copy link

coveralls commented Jul 10, 2016

Coverage Status

Coverage increased (+0.03%) to 74.845% when pulling 3438860 on mronian:addsintegralimage into 581e765 on timholy:master.

@mronian
Copy link
Contributor Author

mronian commented Jul 10, 2016

I've made the changes.

@timholy timholy merged commit 919f480 into JuliaImages:master Jul 11, 2016
@timholy
Copy link
Member

timholy commented Jul 11, 2016

Thanks!

@mronian mronian deleted the addsintegralimage branch July 24, 2016 03:37
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

Successfully merging this pull request may close these issues.

3 participants