ImageTransformations.jl icon indicating copy to clipboard operation
ImageTransformations.jl copied to clipboard

specialize imrotate for 0, 90, 180, 270 degrees

Open johnnychen94 opened this issue 6 years ago • 10 comments

img = testimage("cameraman") # (512, 512)

# Before: (514, 514)
# After: (512, 512)
size(imrotate(img, pi/2))

# Before: sizes are not equal
# After: true
imrotate(imrotate(imrotate(imrotate(img, pi/2), pi/2), pi/2), pi/2) == img

# Before: sizes are not equal
# After: true
imrotate(imrotate(img, pi), pi) == img

johnnychen94 avatar Dec 14 '19 12:12 johnnychen94

Codecov Report

Merging #79 into master will increase coverage by 0.56%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #79      +/-   ##
==========================================
+ Coverage   88.56%   89.12%   +0.56%     
==========================================
  Files           7        7              
  Lines         271      285      +14     
==========================================
+ Hits          240      254      +14     
  Misses         31       31
Impacted Files Coverage Δ
src/warp.jl 100% <100%> (ø) :arrow_up:

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 9c18de9...ca777ff. Read the comment docs.

codecov[bot] avatar Dec 14 '19 13:12 codecov[bot]

I believe this PR is ready for review and merge

johnnychen94 avatar Dec 16 '19 10:12 johnnychen94

is it type stable? was it before this PR?

Evizero avatar Dec 16 '19 10:12 Evizero

Thanks for the comment, I'm already aware of the type stability issue, I'll come back and try to fix that later when I finished the upgrading of Augmentor.jl made by @Evizero (for my own research interest)

johnnychen94 avatar Dec 18 '19 21:12 johnnychen94

BTW, 360 ° seems to be missing.

kimikage avatar Dec 20 '19 22:12 kimikage

BTW, I think it is better to round the rotation matrix instead of quantizing the angle.

kimikage avatar Mar 14 '20 06:03 kimikage

That sounds promising to me!

johnnychen94 avatar Mar 14 '20 06:03 johnnychen94

It seems a bit dangerous to specialize on an approximation for an irrational number. Maybe it would be better to have a degree based version of imrotate and specialize on multiples of 90 like the title suggests? The discretized imrotate could then map to that.

Otherwise, I would really appreciate something like this. It's absence was duly noted when attempting something AoC2020 Day 20: https://adventofcode.com/2020/day/20

mkitti avatar Dec 21 '20 11:12 mkitti

sinpi and cospi could also have some relevance here. https://docs.julialang.org/en/v1/base/math/#Base.Math.sinpi

mkitti avatar Dec 25 '20 17:12 mkitti

I'll let @johnnychen94 decide what to do here, but I put all the tests from this PR into #149 and they pass.

timholy avatar Oct 10 '21 19:10 timholy