code: def create_settings(self):
      self.image_name = ImageSubscriber(
          "Select the input image",
          "None",
          doc="""Select the multichannel image you want to convert to grayscale.""",
      )
  
      self.combine_or_split = Choice(
          "Conversion method",
          [COMBINE, SPLIT],
          doc="""\
  How do you want to convert the color image?
  
  -  *%(SPLIT)s:* Splits the channels of a color
     image (e.g., red, green, blue) into separate grayscale images.
  -  *%(COMBINE)s:* Converts a color image to a grayscale image by
     combining channels together (e.g., red, green, blue)."""
          % globals(),
      )
  
      self.rgb_or_channels = Choice(
          "Image type",
          [CH_RGB, CH_HSV, CH_CHANNELS],
          doc="""\
  This setting provides three options to choose from:
  
  -  *%(CH_RGB)s:* The RGB (red, green, blue) color space is the typical
     model in which color images are stored. Choosing this option will
     split the image into red, green, and blue component images.
  -  *%(CH_HSV)s:* The HSV (hue, saturation, value) color space is based
     on color characteristics such as tint, shade, and tone.
     Choosing this option will split the image into the hue,
     saturation, and value component images.
  -  *%(CH_CHANNELS)s:* Many images contain color channels other than RGB
     or HSV. For instance, GIF and PNG formats can have an alpha
     channel that encodes transparency. TIF formats can have an arbitrary
     number of channels which represent pixel measurements made by
     different detectors, filters or lighting conditions. This setting
     allows you to handle a more complex model for images that
     have more than three channels."""
          % globals(),
      )
  
      # The following settings are used for the combine option
      self.grayscale_name = ImageName(
          "Name the output image",
          "OrigGray",
          doc="""\
  *(Used only when combining channels)*
  
  Enter a name for the resulting grayscale image.""",
      )
  
      self.red_contribution = Float(
          "Relative weight of the red channel",
          1,
          0,
          doc="""\
  *(Used only when combining channels)*
  
  Relative weights: If all relative weights are equal, all three colors
  contribute equally in the final image. To weight colors relative to each
  other, increase or decrease the relative weights.""",
      )
  
      self.green_contribution = Float(
          "Relative weight of the green channel",
          1,
          0,
          doc="""\
  *(Used only when combining channels)*
  
  Relative weights: If all relative weights are equal, all three colors
  contribute equally in the final image. To weight colors relative to each
  other, increase or decrease the relative weights.""",
      )
  
      self.blue_contribution = Float(
          "Relative weight of the blue channel",
          1,
          0,
          doc="""\
  *(Used only when combining channels)*
  
  Relative weights: If all relative weights are equal, all three colors
  contribute equally in the final image. To weight colors relative to each
  other, increase or decrease the relative weights.""",
      )
  
      # The following settings are used for the split RGB option
      self.use_red = Binary(
          "Convert red to gray?",
          True,
          doc="""\
  *(Used only when splitting RGB images)*
  
  Select *"Yes"* to extract the red channel to grayscale. Otherwise, the
  red channel will be ignored.
  """
          % globals(),
      )
  
      self.red_name = ImageName(
          "Name the output image",
          "OrigRed",
          doc="""\
  *(Used only when splitting RGB images)*
  
  Enter a name for the resulting grayscale image coming from the red channel.""",
      )
  
      self.use_green = Binary(
          "Convert green to gray?",
          True,
          doc="""\
  *(Used only when splitting RGB images)*
  
  Select *"Yes"* to extract the green channel to grayscale. Otherwise, the
  green channel will be ignored.
  """
          % globals(),
      )
  
      self.green_name = ImageName(
          "Name the output image",
          "OrigGreen",
          doc="""\
  *(Used only when splitting RGB images)*
  
  Enter a name for the resulting grayscale image coming from the green channel.""",
      )
  
      self.use_blue = Binary(
          "Convert blue to gray?",
          True,
          doc="""\
  *(Used only when splitting RGB images)*
  
  Select *"Yes"* to extract the blue channel to grayscale. Otherwise, the
  blue channel will be ignored.
  """
          % globals(),
      )
  
      self.blue_name = ImageName(
          "Name the output image",
          "OrigBlue",
          doc="""\
  *(Used only when splitting RGB images)*
  
  Enter a name for the resulting grayscale image coming from the blue channel.""",
      )
  
      # The following settings are used for the split HSV option
      self.use_hue = Binary(
          "Convert hue to gray?",
          True,
          doc="""\
  *(Used only when splitting HSV images)*
  
  Select *"Yes"* to extract the hue to grayscale. Otherwise, the hue
  will be ignored.
  """
          % globals(),
      )
  
      self.hue_name = ImageName(
          "Name the output image",
          "OrigHue",
          doc="""\
  *(Used only when splitting HSV images)*
  
  Enter a name for the resulting grayscale image coming from the hue.""",
      )
  
      self.use_saturation = Binary(
          "Convert saturation to gray?",
          True,
          doc="""\
  *(Used only when splitting HSV images)*
  
  Select *"Yes"* to extract the saturation to grayscale. Otherwise, the
  saturation will be ignored.
  """
          % globals(),
      )
  
      self.saturation_name = ImageName(
          "Name the output image",
          "OrigSaturation",
          doc="""\
  *(Used only when splitting HSV images)*
  
  Enter a name for the resulting grayscale image coming from the saturation.""",
      )
  
      self.use_value = Binary(
          "Convert value to gray?",
          True,
          doc="""\
  *(Used only when splitting HSV images)*
  
  Select *"Yes"* to extract the value to grayscale. Otherwise, the
  value will be ignored.
  """
          % globals(),
      )
  
      self.value_name = ImageName(
          "Name the output image",
          "OrigValue",
          doc="""\
  *(Used only when splitting HSV images)*
  
  Enter a name for the resulting grayscale image coming from the value.""",
      )
  
      # The alternative model:
      self.channels = []
      self.add_channel(False)
      self.channel_button = DoSomething(
          "", "Add another channel", self.add_channel
      )
  
      self.channel_count = HiddenCount(self.channels, "Channel count")
  
imports: import re
  import matplotlib.colors
  import numpy
  from cellprofiler_core.image import Image
  from cellprofiler_core.module import Module
  from cellprofiler_core.setting import Binary
  from cellprofiler_core.setting import HiddenCount
  from cellprofiler_core.setting import SettingsGroup
  from cellprofiler_core.setting import ValidationError
  from cellprofiler_core.setting.choice import Choice
  from cellprofiler_core.setting.do_something import DoSomething
  from cellprofiler_core.setting.do_something import RemoveSettingButton
  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 1 for calling the ColorToGray obj's underlying member method code with example usage: obj.create_settings() without return types