NAME
CVIPhalftone - converts a grayscale image to a binary image
SYNOPSIS
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include "CVIPimage.h"
#include "dithers.h"
#include "CVIPhalftone.h"
Image *CVIPhalftone(Image *cvip_Image, int halftone, int
maxval, float fthreshval, CVIP_BOOLEAN retain_image,
CVIP_BOOLEAN verbose)
<cvip_Image> - pointer to input image
<halftone> - indicates method used to convert from grays-
cale to binary. (one of QT_FS, QT_THRESH, QT_DITHER8,
QT_CLUSTER3, QT_CLUSTER4, QT_CLUSTER8)
<maxval> - specifies maximum range of input image (usually
255)
<fthreshval> - threshold value (for QT_THRESH) between [0.0
... 1.0].
<retain_image> - retain image after writing (CVIP_YES or
CVIP_NO)?
<verbose> - shall I be verbose (CVIP_YES or CVIP_NO)?
PATH
$CVIPHOME/CONVERSION/halftone.c
DESCRIPTION
Quantizes a grayscale image to two levels (a binary image).
Possible methods of quantization are: (1) QT_FS -- Floyd -
Steinberg error diffusion, (2) QT_THRESH -- simple thres-
holding, (3) QT_DITHER8 -- Bayer's ordered dither and (4)
QT_CLUSTER3, QT_CLUSTER4 and QT_CLUSTER8 -- three different
sizes of 45-degree clustered-dot dither. Floyd-Steinberg
will almost always give the best looking results.
TYPES AND CONSTANTS
RETURN VALUES
Pointer to a binary image
HISTORY
History information recorded: None
EXAMPLE
include <CVIPtoolkit.h>
#include <CVIPimage.h>
#include <CVIPdef.h>
#include <CVIPconvert.h>
#include <CVIPview.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 gray level to binary
conversion using the QT_THRESH method with threshold
value equal to 0.5 */
cvipImage = CVIPhalftone(cvipImage,QT_THRESH,255,0.5,
CVIP_NO,CVIP_NO);
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
libconverter
NOTES
See Jef Poskanzer's "PBMPLUS"
AUTHOR
Copyright (C) 1996 SIUE - by Scott E. Umbaugh and Greg
Hance.