开发者

Extraction of a part from an image

I want to extract small rectangles from an imag开发者_运维问答e and then want to convert/roll the small rectanges into cylinders. No animation required. I just want to have the cylinders as images.

I am using Perlmagick as API for ImagemagicK.

Any help/suggestions shall be appreciated.


Assuming you know the x,y coordinates and geometry of the rectangles you're trying to extract;

use Image::Magick;
...
my $image = Image::Magick->new();
my $x = $image->Read($filename);
    die "$x" if "$x";

# 100x100 is the size of the cropped image, the +40+40 are giving the x and y
# offsets (i.e. the upper-left coordinate of the cropped image)  
$image->Crop(geometry=>"100x100+40+40"); 

You'll have to be more specific about cylinders, but if it's what I think it is then check Fred's Cylinderize script. The examples given are ImageMagick command-line arguments so there's a bit of work to convert it to the perl equivalent (or you could call them using Perl's exec() function).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜