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

Faster imhist #820

Merged
merged 1 commit into from
Dec 8, 2019
Merged

Faster imhist #820

merged 1 commit into from
Dec 8, 2019

Conversation

yha
Copy link
Contributor

@yha yha commented Sep 19, 2019

Converting each element to real makes the searchsortedlast call dispatch on the faster method specialized for ranges.

Benchmarks:

using BenchmarkTools
using TestImages
img = testimage("lighthouse")
img_gray = Gray.(img)
img_normed = real.(img)
img_float = float.(img_normed)

Before:

@btime imhist($img)           # 24.367 ms (5 allocations: 386.06 KiB)
@btime imhist($img_gray)      # 23.378 ms (3 allocations: 1.92 KiB)
@btime imhist($img_normed)    # 12.228 ms (3 allocations: 1.92 KiB)
@btime imhist($img_float)     # 14.518 ms (3 allocations: 1.92 KiB)

After:

@btime imhist($img)           # 14.108 ms (5 allocations: 386.06 KiB)
@btime imhist($img_gray)      # 12.681 ms (3 allocations: 1.92 KiB)
@btime imhist($img_normed)    # 12.379 ms (3 allocations: 1.92 KiB)
@btime imhist($img_float)     # 13.913 ms (3 allocations: 1.92 KiB)

@codecov
Copy link

codecov bot commented Dec 8, 2019

Codecov Report

Merging #820 into master will increase coverage by 21.09%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #820       +/-   ##
===========================================
+ Coverage   59.36%   80.46%   +21.09%     
===========================================
  Files          10       10               
  Lines        1228      906      -322     
===========================================
  Hits          729      729               
+ Misses        499      177      -322
Impacted Files Coverage Δ
src/exposure.jl 95.02% <ø> (+28.98%) ⬆️
src/labeledarrays.jl 76.92% <0%> (-6.42%) ⬇️
src/Images.jl 33.33% <0%> (ø) ⬆️
src/algorithms.jl 74.2% <0%> (+11.06%) ⬆️
src/convexhull.jl 95.34% <0%> (+14.95%) ⬆️
src/edge.jl 67.7% <0%> (+18.09%) ⬆️
src/bwdist.jl 59.57% <0%> (+21.73%) ⬆️
src/connected.jl 82.22% <0%> (+31.18%) ⬆️
src/corner.jl 82.85% <0%> (+32.85%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 48c4571...75543c2. Read the comment docs.

@yha
Copy link
Contributor Author

yha commented Dec 8, 2019

Rebased

@timholy timholy merged commit e954d11 into JuliaImages:master Dec 8, 2019
@timholy
Copy link
Member

timholy commented Dec 8, 2019

Thanks!

@yha yha deleted the faster-imhist branch May 5, 2020 13:44
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.

2 participants