AIS programs (on file READAIS.DCOM)

Last modified by Richard R. Burton on 13 Dec. 1982


AIS (array of intensity samples) is a format for color and gray level images.  The following functions allows reading and writing of AIS files from lisp.

(AISBLT SourceAisFile SourceX SourceY DestinationBitmap DestinationX DestinationY Width Height How Filter Nbits LoBitAddress)

******* Note:  The reading of an AIS file is done with the normal interrupts turned off. ********* 

    Puts the image in an AIS file into a bitmap.  AISBLT checks the sample size of the AIS file and the number of bits per pixel of the DestinationBitmap and performs the required reduction (if any).  SourceX and SourceY give the left and bottom coordinates in the source file of the image to be read (default to (0,0)).  DestinationBitmap can be a bitmap, a color bitmap or a window.  If it is NIL, a window will be created of the proper size.  
How indicates what method of reduction is to be used if the sample size of the AIS file is larger than the number of bits per pixel in the destination bitmap.  The recognized methods are TRUNCATE (use the high order bits) and FSA (use the Floyd-Steinberg dithering algorithm. The default when going to a 1 bpp bitmap is FSA; otherwise it is TRUNCATE.
   Filter if non-NIL should be an array that will be used to filter the samples read from the AIS file.  If Filter is given and a sample point of intensity N is read from the file, (ELT Filter N) is used to determine the bits for the destination.  The function SMOOTHHIST described below is one way of getting a filter that balances the contrast in an image.
   Nbits and LoBitAddress allow an image to be read into one or more "planes" of a color bitmap.  Nbits tells how many bits are to be taken from each image sample and LoBitAddress indicates the lowest bit within each pixel that the Nbits bits are to go. (Bit address 0 in the leftmost or highest order bit.  For a 4 bit per pixel bitmap, 3 would be the lowest order bit.)  This is used by SHOWCOLORAIS to put the different planes of a color image into the bitmap.

(SHOWCOLORAIS BaseFile ColorMapInfo How ColorBM SourceX SourceY DestinationX DestinationY Width Height)
    *****Note:  Large portions of SHOWCOLORAIS run with the standard interrupts turned off.  ********
    Reads a color image from three ais files into a color bitmap.  The three color files are obtained by concating the strings "-red.ais", "-green.ais" and "-blue.ais" onto the end of BaseFile.  If ColorMapInfo is a list of three small integers, it indicates how many of the bits in the destination are allocated to each color.  For example, if ColorBm is a 4 bit per pixel color bitmap and ColorMapInfo is (1 2 1), 1 bit (bit 0) will be allocated to the red image, 2 bits (bits 1 and 2) will be allocated to the green image and 1 bit (bit 3) will be allocated to the blue image.
ColorBm is the color bitmap the image will be stored into.  It defaults to (COLORSCREENBITMAP).
How, SourceX, SourceY, DestinationX, DestinationY, Width and Height are as described in AISBLT.

An experimental feature that is available only when going to 8 bpp color bitmap: If ColorMapInfo is a color map, each pixel will be determined by finding the color in ColorMapInfo that is closest to the 24 bits of color information read from the three image files.  (This takes a long time.)  The function COLOR.DISTANCE(red green blue redentry greenentry blueentry) is called to calculate the distance by which "closest" color is determined. 

(THREECOLORMAP RedBits GreenBits BlueBits Nbits)
   Returns a color map that assumes the Nbits bits are to be treated as three separate color planes with RedBits bits being in the red plane, GreenBits bits being in the green plane and BlueBits bits being in the blue plane.  Within each plane, the colors are uniformly distributed over the intensity range 0 to 255.

(WRITEAIS ColorBM File Region)
   Writes the region Region of the color bitmap ColorBM onto the file File in AIS format. This provides an efficient way of saving color or gray level images.

(AISHISTOGRAM File Region)
   Returns a histogram array of the region Region in the ais file File.  The histogram array has as its Nth element the number of pixels in the region that have intensity N. 

(GRAPHAISHISTOGRAM Histogram W)
   Draws a graph of a histogram array in the window W.  If W is NIL,  a window is created.

(SMOOTHEDFILTER Histogram)
   Returns a "filter" array that maximally distributes the intensities values contained in Histogram.  The filter array can be passed to AISBLT to change the contrast of the image being read.