JuliaImages / Images.jl

An image library for Julia
http://juliaimages.org/
Other
535 stars 143 forks source link

Preserving rotations and axis flipping #446

Closed Evizero closed 7 years ago

Evizero commented 8 years ago

I'm a little late to the Image.jl party, but I am currently working on a pure Julia image-augmentation library for a deep learning project and I could use a few pointers.

Basically, on a low level, I need to abstract some typical transformations for images with two spatial dimensions, such as axis flipping, rotation, cropping, and resizing.

I kinda solved general rotation after investigating https://github.com/timholy/Images.jl/issues/397 and co. I understand that those don't quite fit into Images.jl because of the dependencies they introduce. So I would put general rotation functions using AffineTransforms.jl and co in my library.

However, I also want to make use of the fact that +/- 90° rotations and axis flipping don't need interpolation. Now naive me thinks those operations would better fit into Images.jl. I went through the code and the closest things I found was ctranspose (kinda) and reflect for 180° rotations.

So my question is, are there fast functions for x and y axis flipping and +/- 90° rotations already, and if not is there interest to have them here? I'd be interested in contributing those.

lucasb-eyer commented 8 years ago

Just adding my vote that I'd be happy to have that.

timholy commented 8 years ago

Do flipud and fliplr work?

timholy commented 8 years ago

Cropping you can get from just img[5:27, 8:43], or getindexim(img, 5:27, 8;43) if you want to preserve the image type wrapper.

Re resizing, there's a non-exported function imresize. Now that we require julia-0.4, I can make use of Interpolations within Images, which will allow quite a few new algorithms. But I haven't gotten around to it (anyone else who is eager is welcome to beat me to it :wink:).

Evizero commented 8 years ago

Do flipud and fliplr work?

perfectly, thanks. Somehow missed them

Now that we require julia-0.4, I can make use of Interpolations within Images, which will allow quite a few new algorithms

Not sure what you mean by that. Do you want to include functions like https://github.com/timholy/AffineTransforms.jl/pull/8 into Images?

I am currently implementing rotation functions based on Interpolations.jl right now. However, I am not really sure how one would best do that with arbitrary dimension, so I'm focusing on 2D (while respecting the the spatial order). I'm also implementing the options to expand the image or crop it to a specified region after rotation, like the following screen shows:

index

Anyhow, I'll push the code as soon as I'm comfortable with it to my repo. I'll ping you if you want, and if you do think it would better fit into Images.jl then I'll be fine adapting it or moving it here.

timholy commented 8 years ago

Not sure what you mean by that. Do you want to include functions like timholy/AffineTransforms.jl#8 into Images?

Well, that and other stuff. At a minimum, I need to figure out where rotate/resize/etc should be best advertised/documented. But I was also thinking about things like log-polar transforms, which need interpolation.

More goodies surrounding affine transforms would be great. Glad you're tackling such problems!

Evizero commented 8 years ago

So this works pretty well for me over at https://github.com/Evizero/Augmentor.jl by using AffineTransforms and I also got elastic transformations working by abusing PiecewiseAffineTransform

displacement

I have read you mention (somewhere recently) that you think it would be worth switching to a different backend for rotations etc? I would like to help with the new Images effort, since I am actively working with images currently, but I am having a hard time finding information on how someone could be of help (or what is actually happening). I have snooped around a bit in your activities and the Images org and the bits of information I was able to find I liked very much. By the way I just saw you Juliacon Talk and I enjoyed it very much.

mronian commented 8 years ago

This is the new repo with all Camera Geometry related functions like projective transforms, homography etc -> https://github.com/JuliaImages/CameraGeometry.jl :smile:

Evizero commented 8 years ago

Ah, I see, thanks. I shall take a close look! I am not that familiar with the domain terminology I will admit, so the package name did not really ring any bells

mronian commented 8 years ago

I am not sure Affine Transforms comes completely under Camera Geometry. In Camera Geometry we use it when we need the image in some other plane with respect to some other camera. So I don't know if AffineTransforms should come under CameraGeometry or under some package like ImageTransforms (with hough transforms, radon transforms etc). Also, something like PiecewiseAffineTransforms would probably be more suited to ImageTranforms.

The CameraGeometry repo is empty right now.....would be awesome if you contribute to it :)

Evizero commented 8 years ago

I'll have to go over the paper you posted there to get a better understanding of the intention. If it aligns (somewhat) with my current project I'll happily try to help