Table of Contents

Name

ppmtocri - convert PPM file (Portable PixMap) to CRI (ERP Compressed Raster Image)

Synopsis

ppmtocri ppmfile crifile [-defpal] [-usepal palfile] [-palname palfile] [-w]

Description

ppmtocri converts a Portable PixMap file to a CRI file. The CRI format is used by the vvsp(2) program for ERP stimulus presentation. As a number of programs are available to convert most all popular graphics file formats into the PPM format, one should be able to easily convert most graphic file formats into CRI format in order to present them in ERP experiments. See the man page for PPM(1) for more information on the PPM format.

ppmfile is the name of the PPM file you wish to convert. ppmfile can be ’-’ to indicate that the stdin should be read in order to facilitate the use of ppmtocri as part of a UNIX pipe. crifile Is the name of the CRI file to be created. If crifile already exists ppmtocri does NOT ask for permission to overwrite it. The options all effect that way that color palettes are used in the conversion process, and are described below.

Here is the basic flow of the ppmtocri program. If no options are given, ppmtocri first tries to do the conversion using the default VVSP palette. If it cannot get an exact match for all the colors in the PPM file using the default palette, it tries to create a new palette (256 entries). If it can’t create a new palette that will fully realize the colors in PPM file (even after reducing each primary to the range 0-63), then it reverts to the default palette and uses a euclidean distance to find the closest color from the default palette for each pixel. The following options can be used:

Options

-usepal palfile
ppmtocri will use the palette file palfile and use euclidean distances to find the closest color match when a pixel in the ppmfile doesn’t exactly match one of the colors in palfile.
-defpal
ppmtocri will use the default VVSP palette, and will use euclidean distances to find the closest color match when a pixel in the pmfile doesn’t exacly match one of the colors in the default palette.
-palname palfile.
If ppmtocri creates a new palette file, it will name it palfile. By default, ppmtocri will create a name for the new palette file by taking the first 8 characters (up to a ’.’) of the crifile and appending the extension ’.pal’ to it.
-w
When creating a new palette file, don’t prompt for overwrite permission if the palette file already exists. The default behavior is to first ask for overwrite permission (Note that ppmtocri does not ask for permission before overwriting an existing CRI file.)

Examples

You have 3 PPM files that you would like to convert to CRI files, and you would like them all to use the same palette file, colors.pal, which you have previously created with editvpal. The PPM files are called desk.ppm, sofa.ppm, and chair.ppm. You would run ppmtocri like this: ppmtocri desk.ppm desk.cri -usepal colors.pal
ppmtocri sofa.ppm sofa.cri -usepal colors.pal
ppmtocri chair.ppm chairdesk.cri -usepal colors.pal

You have a JPEG file called pict1.jpg that you would like to convert into a CRI file. You want to create a palette file for the new CRI file and call it pict1.pal. To do this, use the djpeg(1) program to first convert the JPEG file into a PPM file, and then convert the PPM file into a CRI file. This can be done with a UNIX pipe. Note that the djpeg(1) program has an option for reducing the number of colors during the translation to PPM format. Your command would look like this:
djpeg -colors 256 < pict1.jpg | ppmtocri - pict1.cri -palname pict1.pal

Bugs

None yet reported.

Author

Ron Ohst


Table of Contents