docstr: Create a version of the image appropriate for averaging
  
          
docstr_tok: ["Create","a","version","of","the","image","appropriate","for","averaging"]
code: def preprocess_image_for_averaging(self, orig_image):
      """Create a version of the image appropriate for averaging"""
      pixels = orig_image.pixel_data
      if (
          self.intensity_choice == IC_REGULAR
          or self.smoothing_method == SM_SPLINES
      ):
          if orig_image.has_mask:
              if pixels.ndim == 2:
                  pixels[~orig_image.mask] = 0
              else:
                  pixels[~orig_image.mask, :] = 0
              avg_image = Image(pixels, parent_image=orig_image)
          else:
              avg_image = orig_image
      else:
          # For background, we create a labels image using the block
          # size and find the minimum within each block.
          labels, indexes = centrosome.cpmorphology.block(
              pixels.shape[:2],
              (self.block_size.value, self.block_size.value),
          )
          if orig_image.has_mask:
              labels[~orig_image.mask] = -1
  
          min_block = numpy.zeros(pixels.shape)
          if pixels.ndim == 2:
              minima = (
                  centrosome.cpmorphology.fixup_scipy_ndimage_result(
                      scipy.ndimage.minimum(pixels, labels, indexes)
                  )
              )
              min_block[labels != -1] = minima[labels[labels != -1]]
          else:
              for i in range(pixels.shape[2]):
                  minima = centrosome.cpmorphology.fixup_scipy_ndimage_result(
                      scipy.ndimage.minimum(
                          pixels[:, :, i], labels, indexes
                      )
                  )
                  min_block[labels != -1, i] = minima[
                      labels[labels != -1]
                  ]
          avg_image = Image(min_block, parent_image=orig_image)
      return avg_image
  
imports: import centrosome.bg_compensate
  import centrosome.cpmorphology
  import centrosome.cpmorphology
  import centrosome.filter
  import centrosome.smooth
  import numpy
  import scipy.ndimage
  import skimage.filters
  from cellprofiler_core.image import AbstractImage
  from cellprofiler_core.image import Image
  from cellprofiler_core.measurement import Measurements
  from cellprofiler_core.module import Module
  from cellprofiler_core.pipeline import Pipeline
  from cellprofiler_core.setting import Binary
  from cellprofiler_core.setting import ValidationError
  from cellprofiler_core.setting.choice import Choice
  from cellprofiler_core.setting.subscriber import ImageSubscriber
  from cellprofiler_core.setting.text import Float
  from cellprofiler_core.setting.text import ImageName
  from cellprofiler_core.setting.text import Integer
label_desc: Use image node_id 12 for calling the CorrectIlluminationCalculate obj's underlying member method code with example usage: obj.preprocess_image_for_averaging(orig_image) and returns: avg_image