code: def xray(im, direction='X'):
      r
      im = sp.array(~im, dtype=int)
      if direction in ['Y', 'y']:
          im = sp.transpose(im, axes=[1, 0, 2])
      if direction in ['Z', 'z']:
          im = sp.transpose(im, axes=[2, 1, 0])
      im = sp.sum(im, axis=0)
      return im
docs: r"""
      Simulates an X-ray radiograph looking through the porouls material in the
      specfied direction.  The resulting image is colored according to the amount
      of attenuation an X-ray would experience, so regions with more solid will
      appear darker.
  
      Parameters
      ----------
      im : array_like
          ND-image of the porous material with the solid phase marked as 1 or
          True
  
      direction : string
          Specify the axis along which the camera will point.  Options are
          'X', 'Y', and 'Z'.
  
      Returns
      -------
      image : 2D-array
          A 2D greyscale image suitable for use in matplotlib\'s ```imshow```
          function.