PDL::ImageRGB -- some utility functions for RGB image data handling
Collection of a few commonly used routines involved in handling of RGB, palette and grayscale images. Not much more than a start. Should be a good place to exercise some of the thread/map/clump PP stuff.
Other stuff that should/could go here:
color space conversion
common image filters
quantize and reduce colours in 8-bit images
($out, $lut) = cquant($image [,$ncols]);
This function does color reduction for <=8bit displays and accepts 8bit RGB and 8bit palette images. It does this through an interface to the ppm_quant routine from the pbmplus package that implements the median cut routine which intellegently selects the 'best' colors to represent your image on a <= 8bit display (based on the median cut algorithm). Optional args: $ncols sets the maximum nunmber of colours used for the output image (defaults to 256). There are images where a different color reduction scheme gives better results (it seems this is true for images containing large areas with very smoothly changing colours).
Returns a list containing the new palette image (type PDL_Byte) and the RGB colormap.
Make an RGB image from a palette image and its lookup table.
$rgb = $palette_im->interlrgb($lut)
Input should be of an integer type and the lookup table (3,x,...). Will perform the lookup for any N-dimensional input pdl (i.e. 0D, 1D, 2D, ...). Uses the index command but will not dataflow by default. If you want it to dataflow the dataflow_forward flag must be set in the $lut piddle (you can do that by saying $lut->set_dataflow_f(1)).
Converts an RGB image to a grey scale using standard transform
$gr = $rgb->rgbtogr
Performs a conversion of an RGB input image (3,x,....) to a greyscale image (x,.....) using standard formula:
Grey = 0.301 R + 0.586 G + 0.113 B
Scales a pdl into a specified data range (default 0-255)
$scale = $im->bytescl([$top])
By default $top=255, otherwise you have to give the desired top value as an argument to
bytescl doesn't rescale data that fits already in the bounds 0..$top (it only does the type conversion if required). If you want to force it to rescale so that the max of the output is at $top and the min at 0 you give a negative $top value to indicate this.
This package doesn't yet contain enough useful functions!
Copyright 1997 Christian Soeller <firstname.lastname@example.org> All rights reserved. There is no warranty. You are allowed to redistribute this software / documentation under certain conditions. For details, see the file COPYING in the PDL distribution. If this file is separated from the PDL distribution, the copyright notice should be included in the file.