Bruno Postle > Image-RGBA > Image::RGBA

Download:
Image-RGBA-0.04.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.04   Source  

NAME ^

Image::RGBA - Functions for sampling simple RGBA images

SYNOPSIS ^

'simple', 'bilinear' and 'bicubic' image sampling.

DESCRIPTION ^

Hides some of the ugly stuff involved when sampling individual pixel values from images. A good range of quality levels are provided, currently; simple, linear and spline16.

For an explanation of what is going on, see:

 http://www.fh-furtwangen.de/~dersch/interpolator/interpolator.html

An RGBA image file is very simple, just each channel stored one after the other with no delimiters for each pixel in turn. There is no header data, so you have to know the image dimensions to reconstruct an RGBA image.

USAGE ^

You can start by creating an Image::Magick object:

    my $input = new Image::Magick;
    $input->Read ('input.jpg');

Use an Image::Magick object as the basis of an Image::RGBA object:

    my $rgba = new Image::RGBA (sample => 'linear',
                                 image => $input);

Now you can retrieve a string representing the RGBA pixel values of any point in the original image:

    $values = $rgba->Pixel (20.2354, 839.6556);

Additionally, you can write RGBA pixel values directly to an image by appending the values that need to be written:

    $rgba->Pixel (22, 845, $values);

Note that locations for writing need to be integer values.

You can access the image as an Image::Magick object at any time using the Image method:

    $rgba->Image->Write ('filename.jpg');

OPTIONS ^

SAMPLING TYPES

Note that trying to sample values physically outside of the source image will return a black/transparent pixel value consisting of null bytes.

'simple' sampling is crude non-interpolated pixel sampling, equivalent to the Image::Magick::Get ("pixel[$x,$y]") method. Use this when speed rather than quality is required.

'linear' sampling is fast general purpose pixel sampling, about 3 times slower than 'simple' sampling'. Pixel values are interpolated, so sampling pixel (45.5, 56.6) will get different results to pixel (45, 56).

'spline16' sampling is slow high-quality sampling, about 15 times slower than 'simple' sampling. Interpolated pixel values are just a little bit higher quality than 'linear'.

COPYRIGHT ^

Copyright (c) 2002 Bruno Postle <bruno@postle.net>. All Rights Reserved. This module is Free Software. It may be used, redistributed and/or modified under the same terms as Perl itself.

syntax highlighting: