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

Eager realization #10

Merged
merged 2 commits into from
Jan 1, 2021
Merged

Eager realization #10

merged 2 commits into from
Jan 1, 2021

Conversation

tlnagy
Copy link
Owner

@tlnagy tlnagy commented Jan 1, 2021

This fixes #4. Now, TIFF.jl will fully realize the lazily transformed images before returning them so access times are essentially the same as ImageMagick while preserving a lot of the speed/memory advantages:

Load benchmarking: This PR vs ImageMagick.jl v1.1.6

load time (lower is better) memory usage during load (lower is better)
timing memory

It looks like TIFF.jl beats ImageMagick both in load time and memory usage on every test except involving Packbits compression (capitol.tif) and bali.tif where TIFF.jl fails because of #8.

Access times

But now access times are much improved:

julia> using TIFF, ImageMagick, BenchmarkTools

julia> img = TIFF.load("house.tif");

julia> @btime img[1,1];
  17.500 ns (1 allocation: 16 bytes)

julia> img = ImageMagick.load("house.tif");

julia> @btime img[1,1];
  16.990 ns (1 allocation: 16 bytes)

Limitations

There are still some limitations with images with many planes since I lazily transform each plane and then realize them each round. These lazy transforms currently rely on if/else statements, which is not great. I need to explore offloading this work to compile time and dispatch on the TIFF structure.

this implementation uses the idea from #4 where load the raw data,
lazily apply transformations and then eagerly realize the final
version to reduce the access-time penalty. It might be possible
to refactor this code a bit further to dispatch on the IFD layout
so that I can avoid a lot of these if/else statements and off load
them to compile time.
seems like there was a gap in coverage and this got missed
@codecov-io
Copy link

Codecov Report

Merging #10 (de4d011) into master (751beb0) will increase coverage by 1.87%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #10      +/-   ##
==========================================
+ Coverage   79.78%   81.66%   +1.87%     
==========================================
  Files           9        9              
  Lines         282      289       +7     
==========================================
+ Hits          225      236      +11     
+ Misses         57       53       -4     
Impacted Files Coverage Δ
src/TIFF.jl 100.00% <ø> (ø)
src/load.jl 94.64% <100.00%> (+1.02%) ⬆️
src/types/dense.jl 83.33% <100.00%> (+26.19%) ⬆️

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 751beb0...de4d011. Read the comment docs.

@tlnagy tlnagy merged commit 621e7e7 into master Jan 1, 2021
@tlnagy tlnagy deleted the tn/eager-realization branch January 1, 2021 01:02
tlnagy added a commit that referenced this pull request Jan 8, 2021
This is really a follow-up to #10, now I dispatch differently depending
on whether a TIFF is a single page or not. Additionally, data is read
directly in the final type container, getting rid of most lazy
transformations yielding substantial speed improvements of ~10X.
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.

Loading might be a little too lazy, leading to long access times
2 participants