Des gars qui creusent encore.

That’s it, Summer of Code is over, at least officially.

I finally updated this blog less than I expected. I have to say that after 2 month banging my head to the code, motivation is less than before. So, here is the news:

As announced in my last entry, I worked on a process to invert the computing of the transformation (ie know from where come pixels instead of where they go), to have a good image quality and avoiding aliasing. Here is how it works:

- we set on the image a cage-sized grid
- we apply the deformation to the grid
- we split each grid case to two triangle
- for each pixel inside these triangle, we compute the source coordinates
- finally, we have for each pixel of the final, the coordinate from where to fetch color (sampling)

My first approach for iterating in a triangle was first, re-order it (find the top-high vertice, then left and right vertices), and then iterate it with straight equation. That’s not a great idea. There is a lot of special case, it’s complex and inefficient. Finally, a friend suggested me to proceed recursively, by splitting the triangle in 4, until it include only one pixel. Then, interpolation is done with a barycentric system. Tadaaa, it works every time, and that’s even efficient ! Thanks Théophile (yes, you now have contributed in free software with more than a libcaca patch =) ).

In fact, it’s so efficient that i will probably replace the “forward” method which is currently used for interactive preview (which is also quite ugly).

These is how the tool core looks like. Each circle is a Gegl operation.

- Cage_coef_calc compute, for each pixel that need to be transformed, the coefficient series that the transform algorithm need.
- Cage_transform compute and inverse the transformation
- Render_mapping render the final image.

This architecture allow, with Gegl, easy reussing of this operation. In that case, my tool’s code can be easily reused and adapted to create an iWarp like tool.

To stay in the present, here is the state of things. My tool is in majority done. I mean that the core works well, and it’s usable for a classic utilisation. There is still some teething problem to correct (for instance, it doesn’t works on mask), love to give to UI, and it will be ready for code review and inclusion in master branch of Gimp. At least I hope =)

Here is some deform example:

It ain’t over, but it never was so close to be.

Une bonne chose de faite! =)

Realy nice work. I am looking for a warp tool to transform an image of a map. The starting position is a deformed grid like MapAnalyst produced.

http://mapanalyst.cartography.ch/screenshot/screenshot.html

The form is a list of linked points (n, xi, yi, x’i, y’i) or an ESRI shapefile.

I will try to do the job with gimp.

Chris

I don’t think you can do that with Gimp (or I missed something, that’s possible). However, if you are able to code, you could use an algorithm similar to what i have used in my tool to undeform your map.

See this file: http://git.gnome.org/browse/gimp/tree/app/gegl/gimpoperationcagetransform.c?h=soc-2010-cage-2

Basically, this algorithm can reverse a non-bijective transformation of the plane. In your case, it can compute the undeformed map.

By the way, are you related to MapAnalyst or just a user ? Nice project anyway !