NAME

PDL::PrimaImage - interface between PDL scalars and Prima images


DESCRIPTION

Converts a 2D or 3D PDL scalar into Prima image and vice versa.


SYNOPSIS

  use PDL;
  use Prima;
  use PDL::PrimaImage;

  my $x = byte([ 10, 111, 2, 3], [4, 115, 6, 7]);
  my $i = PDL::PrimaImage::image( $x);
  $i-> type( im::RGB);
  $x = PDL::PrimaImage::piddle( $i);


image PDL, %OPTIONS

Converts 2D or 3D piddle into Prima image. The resulting image pixel format depends on the piddle type and dimension. The 2D array is converted into one of im::Byte, im::Short, im::Long, im::Float, or im::Double pixel types.

For 3D arrays each pixel is an array on values. image accepts piddles with tuple and triple values. For tuple, the resulting pixel format is complex ( with im::ComplexNumber bit set), where each pixel contains 2 values, either float or double, correspondingly to <im::Complex> and im::DComplex pixel formats.

For triple values, im::RGB pixel format is assumed. In this format, each image pixel is represented as a single combined RGB value.

To distinguish the degenerate cases, like ([1,2,3],[4,5,6]), where it is impossible to guess whether the piddle is a 3x2 gray pixel image or a 1x2 RGB image, %OPTIONS hash is used. When either rgb or complex boolean value is set, image assumes the piddle is a 3D array. If neither option is set, image favors 2D array semantics. NB: These hints are neither useful nor are checked when piddle format is explicit, and should only be used for hinting an ambiguous data representation.


piddle IMAGE, %OPTIONS

Converts Prima image into a piddle. Depending on image pixel type, the piddle type and dimension is selected. The following table depicts how different image pixel formats affect the piddle type:

   Pixel format      PDL type    PDL dimension 
   --------------------------------------------
   im::bpp1            byte            2       
   im::bpp4            byte            2       
   im::bpp8            byte            2
   im::Byte            byte            2
   im::Short           short           2
   im::Long            long            2
   im::Float           float           2
   im::Double          double          2
   im::RGB             byte            3
   im::Complex         float           3
   im::DComplex        double          3
   im::TrigComplex     float           3
   im::TrigDComplex    double          3

Image in pixel formats im::bpp1 and im::bpp4 are converted to im::bpp8 before conversion to piddle, so if raw, non-converted data stream is needed, in correspondingly 8- and 2- pixels perl byte format, raw boolean option must be specified in %OPTIONS. In this case, the resulting piddle width is aligned to 4-byte boundary.


CONSIDERATIONS

Prima image coordinate origin is located in lower left corner. That means, that an image created from a 2x2 piddle ([0,0],[0,1]) will contain pixel with value 1 in the upper right corner.

See I for more.


FUNCTIONS


image2piddle

  Signature: (data(z,w,h); SV * imagesv; int image2piddle; int mpixel)

info not available


TROUBLESHOOTING

Undefinedned symbol "gimme_the_vmt"

The symbol is contained in Prima toolkit. Include 'use Prima;' in your code. If the error persists, it is probably Prima error; try to re-install Prima. If the problem continues, try to change manually value in 'sub dl_load_flags { 0x00 }' string to 0x01 in Prima.pm - this flag is used to control namespace export ( see Dynaloader for more ).


AUTHOR

Dmitry Karasik, <dmitry@karasik.eu.org>.


SEE ALSO

The Prima toolkit, http://www.prima.eu.org/

The PDL toolkit, http://pdl.perl.org/