laszlo kiss on  wrote...
| <<
| The original picture is any TIFF file.
| There are about 5 known points (x,y).
|
| Now I have to create a new picture in which the
| section (accordingly  to the position of the 5 points
| in the TIFF) inside the 5 point polygon have to be
| stored.
|
| Is this possible with IM? I hope you can help and
| particularly understand me. Thanks a lot!
| Sven>>
|
| If I understand well the problem is to copy part of an
| Image inside a polygon onto an other image.
|
Hmmm...  I would say deleting the area outside the polygon would be the
better way to think of it.

First draw a polygon on a transparent image the same size as the
original TIFF

   convert image.tiff -matte -fill none -draw 'color 0,0 reset' \
           -fill white -draw 'polygon x1,y1,x2,y2,x3,y3,x4,y4,x5,y5' \
           polygon.png

Now make either the area outside the polygon transparent

   convert image.tiff -matte polygon.png \
           -compose DstIn -composite  image_trans.png

make it white...

   convert polygon.png -channel Matte -separate +matte image.tiff \
           -compose screen -composite    image_white.png

Make if black..

   convert polygon.png -channel Matte -separate +matte \
           +channel -negate image.tiff \
           -compose multiply -composite    image_black.png

For more info see, Alpha Compositing and Channels/Masks in IM examples
  http://www.cit.gu.edu.au/~anthony/graphics/imagick6/

| AFAIK there is no command line resolution for that,
| but using any program interfaced to ImageMagick you
| can
| load the image to ImageMagick, scan it bit by bit and
| if the scanned point is inside the polygon use
| Get("pixel[x,y]") and Set("pixel[x,y]->color")
| commands to copy the pixel to the other image.
| The google has plenty of "inside a polygon"
| algorithms.
|
| If the 'other image' is a transparent rectangle, then
| the result will be shown as a cut image.
|
These are not good methods and denote thinking able image handling at
too low a level.  The better way is to think in terms of whole images,
masks and image compositions.


  Anthony Thyssen ( System Programmer )    <[EMAIL PROTECTED]>
 -----------------------------------------------------------------------------
  You are caught in a maze of twisty little Sendmail rules, all obscure.
 -----------------------------------------------------------------------------
     Anthony's Home is his Castle     http://www.cit.gu.edu.au/~anthony/
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to