Package for affine transforms and scaling of images

268 views
Skip to first unread message

HarrydB

unread,
Oct 12, 2011, 10:34:28 AM10/12/11
to golang-nuts
Hi all,
I wrote a package that can perform affine transforms and scaling of
image which I put on github for whoever is interrested.

Affine transforms:
- Translate
- Zoom
- Shear
- Rotate

Interpolation methods:
- Nearest neighbour
- Bilinear
(- Bicubic)

I wrote generic functions that can work on any image.Image and
specific functions that work with the Pix data directly for bilinear
interpoliation of image.RGBA and image.Gray. Those are actually faster
than the generic nearest neighbour.

After these were finished a scaling function was just a few lines.
The bicubic interpolation one has a bug at the border but it seems to
work fine for scaling.

The code that works with the latest weekly can be found at:
https://github.com/harrydb/go/tree/master/image/transform
For releases this might work:
https://github.com/harrydb/go/tree/5fcb68c3b87312db886a9281617a5c5b00f4f79a/image/transform

Cheers,
Harry

David Crawshaw

unread,
Oct 13, 2011, 4:55:53 PM10/13/11
to HarrydB, golang-nuts
Hi Harry. I have been working on similar image ops:

http://code.google.com/p/graphics-go/

HarrydB

unread,
Oct 18, 2011, 3:47:09 PM10/18/11
to golang-nuts
Hey David, I did not know that, thanks for pointing it out.

Your code looks good but I needed shear anyway. If you are planning to
add affine transforms to you can use my code as a start if you want.
--
Harry

laurent

unread,
Nov 3, 2011, 9:39:24 AM11/3/11
to golan...@googlegroups.com
Hi Harry,
Good job.
For your information I wrote code in the same spirit as your affine transformation (but not documented):
I would be glad to use your transformation package if I 'll be sure you continue to support your code.
How can I use your transformation in my code.
cheers
Laurent Le Goff

HarrydB

unread,
Nov 3, 2011, 6:43:32 PM11/3/11
to golang-nuts
Hi Laurent,

I am not sure. I will try to keep it working with new releases but I
will not have a lot of spare time as I am going to write my Master
thesis this year (and work to pay for it). You are free to make a
local copy of my code and use/modify it however you want. If you want
something that is better supported, maybe it is an idea to adapt the
my or your own affine code to use the go-graphics lib mentioned by
David above (I have not tried their code yet btw, and I don't know
what their plans are).

For an example use of my code see the example.go file:
https://github.com/harrydb/go/blob/master/image/transform/example.go

Let me know if you create anything nice!
--
Harry

On Nov 3, 2:39 pm, laurent <legoff.laur...@gmail.com> wrote:
> Hi Harry,
> Good job.
> For your information I wrote code in the same spirit as your affine
> transformation (but not documented):http://code.google.com/p/draw2d/source/browse/draw2d/rgba_interpolati...http://code.google.com/p/draw2d/source/browse/draw2d/transform.go

HarrydB

unread,
Nov 13, 2011, 6:48:03 PM11/13/11
to golang-nuts
A heads up: I just saw graphics-go added affine transforms, I suggest
using their package.
Reply all
Reply to author
Forward
0 new messages