NAME
bit_compress, bit_decompress, bitplane_sep - Performs bit-
plane runlength coding
SYNOPSIS
#include "CVIPtoolkit.h"
#include "CVIPconvert.h"
#include "CVIPdef.h"
#include "bitplane_RLC.h"
#include <sys/types.h>
#include <sys/stat.h>
int bit_compress(Image *inputImage, char *filename, byte
sect )
<inputImage> - pointer to the image
<filename> - pointer to a character array
<sect> - bitmask of planes to retain
Image *bit_decompress(char *filename)
<filename> - pointer to a character array
Image *bit_planeadd(char *filename)
<filename> - pointer to a character array
Image *bitplane_sep(Image *input_Image, char *string)
<input_Image> - pointer to an Image
<string> - string containing bits to retain (7,6,5,...,0)
PATH
$CVIPHOME/COMPRESSION/bitplane_RLC.c
DESCRIPTION
bit_compress takes three parameters, the input Image
pointer, the filename to store the encoded data, and the
bits to retain. This algorithm decomposes the input image
into eight binary bitplanes each corressponding to each bit
position in an eight bit binary. Then each bitplane is run-
length coded separately and written into an individual file
name derived from the input filename. The user is advised
not to provide the extension for the filename because the
program automaticaly appends suitable extension with numbers
to identify the bitplane files.
bit_decompress takes a pointer to the encoded data file
name, and returns a pointer to the decompressed image.
Since there are eight files with the same name with dif-
ferent extension(each file corresponds to a bitplane), the
program automatically derives the extension and decodes each
file sequentialy. So, the user is advised not to enter the
extension. Even the user enters a wrong extension the pro-
gram takes care of it by appending the proper extension. It
generates seven images and returns the pointer to the eigth
image. Each image corresponds to the one of the eight bit-
plane of the originalimage.
bit_planeadd takes a pointer to the character array and
returns pointer to the image. The character array represents
the filename to be decoded(without any extension). The same
explainations for no extension as discussed in the above
paragraph applies here too. The operation is same as
bit_decompress except it allows the user to add any combina-
tion of bitplanes together and display the resultant image.
The user is advised not to add the same bitplane twice as it
makes no sense. It returns the pointer to the resultant
image.
TYPES AND CONSTANTS
RETURN VALUES
bit_compress: 0 on success, -1 on failure
bit_decompress, bit_planeadd: a valid Image pointer on suc-
cess, a NULL pointer on failure
HISTORY
History information recorded: None
DIAGNOSTICS
The Bit plane Runlength coding and decoding algorithm was
designed to work only on monochrome image(.pgm). Eight
files are derived from the filename passed in the command
line or entered by the user, by appending proper extension.
So, the user has to enter the filename without any extension
wherever he or she needs to enter the filename.
EXAMPLE
#include <CVIPtoolkit.h>
#include <CVIPimage.h>
#include <CVIPdef.h>
#include <CVIPconvert.h>
#include <CVIPview.h>
#include "bitplane_RLC.h"
#include <sys/types.h>
#include <sys/stat.h>
#define VIEWER "picture"
#define VIDEO_APP "SunVideo &"
void main()
{
Image *cvipImage;
IMAGE_FORMAT format;
char *inputfile,*outputfile;
(void) setDisplay_Image(VIEWER, "Default");
print_CVIP("\n\t\tEnter the Input File Name: ");
inputfile =(char *) getString_CVIP();
format = getFormat_CVIP(inputfile);
cvipImage = read_Image(inputfile,1);
view_Image(cvipImage, inputfile);
free(inputfile);
/* the following call performs the bit plane run length
coding on the inputnput image retaining only the most
significant bit and the data is stored in "file1" */
bit_compress(cvipImage,"file1",128);
/* the following call performs the bit plane run length
decoding of the input image */
cvipImage=bit_decompress("file1");
print_CVIP("\n\t\tEnter the Output File Name: ");
outputfile = getString_CVIP();
view_Image(cvipImage,outputfile);
write_Image(cvipImage,outputfile,CVIP_NO,CVIP_NO,format,1);
free(outputfile);
}
SEE ALSO
libcompress
AUTHOR
Muthu kumar, Southern Illinois University at Edwardsville
Copyright (C) 1995 SIUE - by Scott Umbaugh and Muthu kumar.