Copy polygonal subset of an image
In a message of Fri, 28 Aug 2015 13:30:57 -0700, Marc Camacho Cateura writes:
>For a project, I need to copy a polygonal subset of an image. I have eight points of panoramic image, and I want to copy this subset onto another panoramic image.
>I find ways to do this with PIL but only with a box mask. And I need a polygonal subset from the eight points...
>I'm new in python and I don't know how to do this... maybe with numpy and Pil?
>I apreciate some help...
>Thank you very much and best regards!
Pillow is the maintained fork of PIL, but alas, it will not help you either
as it really wants rectangles as well.
For problems of this sort I use the GIMP.
If this is something you have to do with only a few images, and then you
are done for good, just do it by hand. But if you need to do this
regularly, the good news is that you can script the gimp with python.
The bad news is that the documentation -- unless it has improved over
the last 3 years -- is really incomplete. The other good news is
that there is a gimp irc where helpful people hang out.
The other question I have for you is, do you happen to speak French?
irc://irc.gimp.org/#gimp-fr is perhaps even more helpful, and there
is an extremely good 'scripting gimp with python' tutorial I remember,
but I also remember it is in French. I have lost the link, alas, but
I could go try to find it -- or you can ask in that channel, I think
that is where I heard about it -- if this is an option for you.
Note, before you try to write any plugin/script in python for the GIMP
you should really spend several hours playing with the thing and
manipulating images just for fun there. Not only to do what you want
(which takes almost no time) but to get familiar with the gimp way of
doing things. Otherwise any gimp-python tutorial is going to say
'first we need to add a second layer and we will set the opacity to ...'
and you will be scratching your head and thinking 'what is a layer?
what does it mean to have an opacity?'
Hope this helps,
But for what it is worth, I am _absolutely certain_ that you can do
what you want with a python-fu (that is what they call it) plugin.
I needed to take an set of images and chop them up into hexagons for
a wargame I wrote, and it worked great. If that plugin hadn't gone
to the great bit-bucket in the sky sometime in my year of destroying
4 laptops, I would just send you the code.
While the people on the gimp irc are much more knowledgable than I am,
do not hesitate to pester me for help to get your thing working,
especially if you think your problem is more along the 'I think I am
not understanding Python' lines than the 'I don't know how to make
Gimp do this thing'.