Re: Picture on a ball canvas

Luis Menina <[email protected]>
Newsgroups gmane.comp.gnome.love
Message-ID <[email protected]>
Hi Blagoj,

Le 27/11/2011 09:44, Blagoj Kupev a écrit :
> Thanks for your reply, it was not late. After your mail i've been trying
> to use cairo and i must say it is amazing. :)

Happy that was useful :-)

> I've been looking into usage of matrix functionality, but i'm still
> uncertain how to achieve what i'm looking for. As i've understood the
> "matrix functionality", it is applied between user and device "space"
> and it is one matrix for all pixels. I beleive that i need to apply
> several matrices for the whole picture to get different "distortions" on
> different parts of the picture.

Well, AFAIR, using several matrixes can always be reduced to one single 
matrix. You should give a look to barrel distortion and pincushion 
distortion:
http://en.wikipedia.org/wiki/Lens_Distortion

Some specialized free software already do that kind of distortion 
correction. This is the case for the panorama tools:
http://wiki.panotools.org/Lens_correction_model

You may also find some GIMP plugins for that, and find out how which 
matrix they're using, or see how it's done in hugin (frome the panora 
tools):
http://libregraphicsworld.org/blog/entry/creating-lens-distorsion-models-with-hugin-lens-calibrator

> I think that function cairo_user_to_device  will do the work to define
> different matrices for each pixel, but i do not know how to use it. To
> me it seems that it is only calculating the position of the pixel based
> on content of CTM. But then i do not see for which purpose i can use
> this function?

Well, in general, you don't even care! You just need to define the right 
matrix transformation, draw normaly your image, and the final result 
will be drawn according to your matrix: your distorded image.

> BTW, do you know how can i put different matrices for different parts of
> the picture?

I'm not even sure that's what you need. I'm pretty sure you can do it 
all with one single matrix, with some variable values in it.

The Wikipedia also gives a link to this page which has all the thery 
behind it:
http://www.ipol.im/pub/algo/ags_algebraic_lens_distortion_estimation/

Good luck,
--
Luis
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.