%N readbcg %F $MIR/src/subs/cgsubs.for
%D Read in mask image mask
%P nebk
%: plotting
%B
      subroutine readbcg (init, lun, ibin, jbin, krng, blc, trc,
     *                    bimage, blanks)

      logical bimage(*)
      integer lun, blc(*), trc(*), ibin(2), jbin(2), krng(2)
      logical blanks, init
  ---------------------------------------------------------------------
  Read in the blanking mask from the specified window from the image
  When reading more than one plane, the mask image pixel is considered
  blanked if any of the planes are blanked at that pixel.  When
  spatially binning images, a binned pixel is considered blanked if
  any of the input pixels were blanked.

  Input:
    init        If true initialize BINMAGE to all good first
    lun         Handle of image
    ibin        Increment and average for i direction
    jbin        Increment and average for j direction
    krng        First pixel in k direction to read and number of
                pixels to average
    blc,trc     Window to read
  Input/Output
    blanks      True if there are blanked pixels in bimage
  Output
    bimage      Masking image.  True means a good pixel (unflagged) and
                false means bad (flagged pixel).  Will be bad if any
                pixel in spectral range is bad for each spatial pixel
