NAME

     threshold_segment - performs a binary threshold on an image

SYNOPSIS

      #include "CVIPtools.h"
      #include "CVIPimage.h"
      #include "CVIPdef.h"
      #include <stdio.h>
      #include "threshold.h"

      Image *threshold_segment(Image  *inputImage,  unsigned  int
     threshval, CVIP_BOOLEAN thresh_inbyte)

      <inputImage> - pointer to Image structure
      <threshval> - threshold value
      <thresh_inbyte>
               - CVIP_NO apply threshval directly to image data;
               - CVIP_YES  threshval is CVIP_BYTE range; remap to
     image
                       data range before thresholding.

PATH

     $CVIPHOME/SEGMENTATION/threshold.c

DESCRIPTION

     This function performs a binary threshold on an input image.
     It  sets  pixels  of  value greater than <threshval> to 255;
     those less than or equal to <threshval>  are  set  to  zero.
     Each  band of a multi-band images is thresholded separately.
     If <thresh_inbyte> is 0, <threshval> is applied directly  to
     the  image  data.  If <thresh_inbyte> equals 1,  <threshval>
     is remapped to  its  corresponding  CVIP_BYTE  value  before
     thresholding according to the formula:

                    <threshval> x (max_val - min_val)
     <new_thresh> = --------------------------------- + min_val
                                  255

     where max_val and min_val are the maximum and minimum values
     found in the image.  This option is provided for consistancy
     with the method used to display histograms in  CVIPtools  --
     histograms  are  remapped to CVIP_BYTE range, 0 to 255. With
     this option the user can select a threshold  value  directly
     from the histogram.

TYPES AND CONSTANTS

      None

RETURN VALUES

     A thresholded image.

BUGS

     None at this time

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;

      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 binary threshold
      on the input image with the threshval equal to 128 */
      cvipImage = (Image *)threshold_segment(cvipImage,128,
      CVIP_YES);
      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

     libsegment

AUTHOR

     Copyright (C) 1995, 1996 SIUE - by Scott Umbaugh,  Kun  Luo,
     and Yansheng Wei.