code: def create_settings(self):
      self.images_list = ImageListSubscriber(
          "Select images to measure",
          [],
          doc="""Select images in which to measure the granularity.""",
      )
  
      self.divider_top = Divider(line=True)
  
      self.wants_objects = Binary(
          "Measure within objects?",
          False,
          doc="""\
          Press this button to capture granularity measurements for objects, such as
          those identified by a prior **IdentifyPrimaryObjects** module.
          **MeasureGranularity** will measure the image’s granularity within each
          object at the requested scales.""",
      )
  
      self.objects_list = LabelListSubscriber(
          "Select objects to measure",
          [],
          doc="""\
          *(Used only when "Measure within objects" is enabled)*
  
          Select the objects within which granularity will be measured.""",
      )
  
      self.divider_bottom = Divider(line=True)
      self.subsample_size = Float(
          "Subsampling factor for granularity measurements",
          0.25,
          minval=numpy.finfo(float).eps,
          maxval=1,
          doc="""\
          If the textures of interest are larger than a few pixels, we recommend
          you subsample the image with a factor <1 to speed up the processing.
          Downsampling the image will let you detect larger structures with a
          smaller sized structure element. A factor >1 might increase the accuracy
          but also require more processing time. Images are typically of higher
          resolution than is required for granularity measurements, so the default
          value is 0.25. For low-resolution images, increase the subsampling
          fraction; for high-resolution images, decrease the subsampling fraction.
          Subsampling by 1/4 reduces computation time by (1/4) :sup:`3` because the
          size of the image is (1/4) :sup:`2` of original and the range of granular
          spectrum can be 1/4 of original. Moreover, the results are sometimes
          actually a little better with subsampling, which is probably because
          with subsampling the individual granular spectrum components can be used
          as features, whereas without subsampling a feature should be a sum of
          several adjacent granular spectrum components. The recommendation on the
          numerical value cannot be determined in advance; an analysis as in this
          reference may be required before running the whole set. See this `pdf`_,
          slides 27-31, 49-50.
  
          .. _pdf: http://www.ravkin.net/presentations/Statistical%20properties%20of%20algorithms%20for%20analysis%20of%20cell%20images.pdf""",
      )
  
      self.image_sample_size = Float(
          "Subsampling factor for background reduction",
          0.25,
          minval=numpy.finfo(float).eps,
          maxval=1,
          doc="""\
          It is important to remove low frequency image background variations as
          they will affect the final granularity measurement. Any method can be
          used as a pre-processing step prior to this module; we have chosen to
          simply subtract a highly open image. To do it quickly, we subsample the
          image first. The subsampling factor for background reduction is usually
          [0.125 – 0.25]. This is highly empirical, but a small factor should be
          used if the structures of interest are large. The significance of
          background removal in the context of granulometry is that image volume
          at certain granular size is normalized by total image volume, which
          depends on how the background was removed.""",
      )
  
      self.element_size = Integer(
          "Radius of structuring element",
          10,
          minval=1,
          doc="""\
          This radius should correspond to the radius of the textures of interest
          *after* subsampling; i.e., if textures in the original image scale have
          a radius of 40 pixels, and a subsampling factor of 0.25 is used, the
          structuring element size should be 10 or slightly smaller, and the range
          of the spectrum defined below will cover more sizes.""",
      )
  
      self.granular_spectrum_length = Integer(
          "Range of the granular spectrum",
          16,
          minval=1,
          doc="""\
          You may need a trial run to see which granular
          spectrum range yields informative measurements. Start by using a wide spectrum and
          narrow it down to the informative range to save time.""",
      )
  
imports: import logging
  import cellprofiler_core.workspace
  import numpy
  import scipy.ndimage
  import skimage.morphology
  from cellprofiler_core.constants.measurement import COLTYPE_FLOAT
  from cellprofiler_core.module import Module
  from cellprofiler_core.setting import Divider, Binary, ValidationError
  from cellprofiler_core.setting.subscriber import ImageListSubscriber, LabelListSubscriber
  from cellprofiler_core.setting.text import Float, Integer
  from centrosome.cpmorphology import fixup_scipy_ndimage_result
  from cellprofiler.gui.help.content import image_resource
label_desc: Use image node_id 1 for calling the MeasureGranularity obj's underlying member method code with example usage: obj.create_settings() without return types