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

Applying rotation using Images.jl #640

Closed
ereday opened this issue Jun 6, 2017 · 3 comments
Closed

Applying rotation using Images.jl #640

ereday opened this issue Jun 6, 2017 · 3 comments

Comments

@ereday
Copy link

ereday commented Jun 6, 2017

I couldn't find an example from which I could undestand usage of rotate. I tried the following but failed to rotate & save original image.
Edit
I prefer not to loose anyting from the image and for this I guess, I need to to add padding to this workflow too.


img = load("my_img.png") # 320×480 Array{RGBA{N0f8},2}:
tfm = recenter(RotMatrix(pi/8), center(img))
imgrot = warp(img, tfm)
save("rotated_my_img.png",imgrot)

@timholy
Copy link
Member

timholy commented Jun 9, 2017

Works for me. Using the "lighthouse" image from TestImages:
rotated_my_img

As you can see, padding is added for you.

If you want more help, you'll have to be more explicit about what exactly is going wrong. Make sure you're using Images, CoordinateTransformations.

@ereday
Copy link
Author

ereday commented Jun 9, 2017

Thanks for the reply. I tried the same thing by using lighthouse image you mentioned:

using Images,TestImages,CoordinateTransformations
img = testimages("lighthouse") # 512×768 Array{RGB4{N0f8},2}
tfm = recenter(RotMatrix(pi/8), center(img)) 
imgrot = warp(img, tfm)

WARNING: 'warp(img, tform)' is deprecated in favour of the new interpretation 'warp(img, inv(tform))'. Set 'const warp = ImageTransformations.warp_new' right after package import to change to the new behaviour right away. See JuliaImages/ImageTransformations.jl#25 for more background information
in depwarn(::String, ::Symbol) at ./deprecated.jl:64
in warp_old(::Array{ColorTypes.RGB4{FixedPointNumbers.Normed{UInt8,8}},2}, ::CoordinateTransformations.AffineMap{Rotations.RotMatrix{2,Float64,4},StaticArrays.SVector{2,Float64}}) at /Users/ereday/.julia/v0.5/ImageTransformations/src/warp.jl:124
in eval(::Module, ::Any) at ./boot.jl:234
in eval(::Module, ::Any) at /usr/local/Cellar/julia/0.5.0/lib/julia/sys.dylib:?
in eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:64
in macro expansion at ./REPL.jl:95 [inlined]
in (::Base.REPL.##3#4{Base.REPL.REPLBackend})() at ./event.jl:68
while loading no file, in expression starting on line 0
-127:640×-68:837 OffsetArray{RGB4{N0f8},2}:

Now, If I try to save imgrot with:
save("rotated_lhouse.jpg",imgrot)

I got first an error which states:

Errors encountered while saving "rotated_lhouse.jpg".
All errors:
MethodError(QuartzImageIO.to_explicit,(

and then millions of numbers starts to appear in the terminal and session is locked.
`

My operating system is OSX and I'm using Julia v0.5.

@timholy
Copy link
Member

timholy commented Jun 9, 2017

This needs fixing in QuartzImageIO.jl (can you please report this there?) You can work around the bug with save("rotated_lhouse.jpg", parent(imgrot)). See this blog post for more information.

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

No branches or pull requests

2 participants