## NAME

         histeq - performs histogram equalization

## SYNOPSIS

          #include <stdio.h>
          #include "CVIPimage.h"
          #include "CVIPdef.h"
          #include "CVIPcolor.h"
          #include "CVIPhisto.h"

         Image *histeq(Image *in, int band)
          <in> - a pointer to an Image structure
          <band> - which band (0,1, or 2) to operate on;  use  0  for
         gray

## PATH

          $CVIPHOME/HISTOGRAM/histeq.c

## DESCRIPTION

         This function performs a histogram equalization (histeq)  on
         an  input  image.   Histeq distributes the gray level values
         within an image as evenly as possible. The goal of histeq is
         a flat histogram.

         The function works with color or grayscale  images.  With  a
         color  image, the user specifies band 0, 1, or 2 as the band
         to use for histogram calculations.  For a  grayscale  image,
         specify  band  '0'.  The  function  automatically  casts any
         CVIP_INTEGER,   CVIP_FLOAT   or   CVIP_DOUBLE   image   into
         CVIP_SHORT.   It   operates   directly  on  images  of  type
         CVIP_SHORT and CVIP_BYTE.

## TYPES AND CONSTANTS

         None

## RETURN VALUES

         Returns a histogram-equalized image.

## HISTORY

         History information recorded: None

## EXAMPLE

          #include <CVIPtoolkit.h>
          #include <CVIPdef.h>
          #include <CVIPimage.h>
          #include <CVIPconvert.h>
          #include "CVIPcolor.h"
          #include "CVIPhisto.h"

          void main()
          {
          Image *cvipImage;
          IMAGE_FORMAT format;
          char *inputfile, *outputfile;
          int mb=0;
          setDisplay_Image("picture", "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);

          if(cvipImage->bands>1) {
          printf("This function preserves relative
          colors.\n");
          printf("Select the band on which to calculate\n");
          printf("the histogram (0=Red, 1=Green, 2=Blue)\n");
          mb=getInt_CVIP(10,0,2);
          }
          if(cvipImage->image_ptr[0]->data_type > CVIP_SHORT){
          cvipImage=condRemap_Image(cvipImage, CVIP_SHORT,
          0, 32767);
          }
          cvipImage =(Image *)histeq(cvipImage,mb);
          cvipImage = remap_Image(cvipImage, CVIP_BYTE,0,255);

          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(inputfile);
          free(outputfile);
          }

## BUGS

         None at this time

## SEE ALSO

## AUTHOR

         Copyright (C) 1996 SIUE - by Scott Umbaugh and Arve Kjoelen.