Image-RGBA
view release on metacpan or search on metacpan
lib/Image/Photo.pm view on Meta::CPAN
package Image::Photo;
=head1 NAME
Image::Photo - Functions for sampling simple Photographic images
=head1 SYNOPSIS
Photographic lens correction.
=head1 DESCRIPTION
An extension of the Image::RGBA suitable for sampling photographic
images
Provided is optional radial luminance correction - Suitable for sampling
photographs where there is a known light falloff from the centre of the
image to the edges.
Also radial lens distortion can be corrected at the same time.
=head1 USAGE
You can start by creating an Image::Magick object:
my $input = new Image::Magick;
$input->Read ('input.jpg');
=cut
use strict;
use warnings;
use Image::RGBA;
use vars qw /@ISA/;
@ISA = qw /Image::RGBA/;
our $VERSION = '0.01';
=pod
Use an Image::Magick object as the basis of an Image::Photo
object:
my $rgba = new Image::Photo (sample => 'linear',
radlum => 0,
image => $input,
a => 0.0,
b => -0.2,
c => 0.0);
The parameters 'sample', 'radlum', 'a', 'b' and 'c' are quality settings
(see descriptions below).
=cut
sub new
{
my $class = shift;
$class = ref $class || $class;
my $params = {@_};
#my $self = new Image::RGBA (%$params);
my $self = $class->SUPER::new (%$params);
# various photo calculations reuse values derived from the width
# and height. May as well calculate them at the start.
$self->{w2} = $self->{width} / 2;
$self->{h2} = $self->{height} / 2;
if ($self->{width} < $self->{height}) { $self->{diameter} = $self->{width} }
else { $self->{diameter} = $self->{height} }
$self->{radius} = $self->{diameter} / 2;
# attributes specific to photos
$self->{radlum} = $params->{radlum} || 0;
$self->{a} = $params->{a} || 0;
$self->{b} = $params->{b} || 0;
$self->{c} = $params->{c} || 0;
# bless $self, $class;
return $self;
}
=pod
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);
( run in 1.072 second using v1.01-cache-2.11-cpan-39bf76dae61 )