code: def main():
      # parse cmd arguments
      parser = getParser()
      parser.parse_args()
      args = getArguments(parser)
  
      # prepare logger
      logger = Logger.getInstance()
      if args.debug:
          logger.setLevel(logging.DEBUG)
      elif args.verbose:
          logger.setLevel(logging.INFO)
  
      # load input image
      image_smoothed_data, image_header = load(args.input)
  
      # perform opening resp. closing
      # in 3D case: size 1 = 6-connectedness, 2 = 12-connectedness, 3 = 18-connectedness, etc.
      footprint = scipy.ndimage.generate_binary_structure(
          image_smoothed_data.ndim, args.size
      )
      if "erosion" == args.type:
          logger.info("Applying erosion...")
          image_smoothed_data = scipy.ndimage.binary_erosion(
              image_smoothed_data, footprint, iterations=args.iterations
          )
      elif "dilation" == args.type:
          logger.info("Applying dilation...")
          image_smoothed_data = scipy.ndimage.binary_dilation(
              image_smoothed_data, footprint, iterations=args.iterations
          )
      elif "opening" == args.type:
          logger.info("Applying opening...")
          image_smoothed_data = scipy.ndimage.binary_opening(
              image_smoothed_data, footprint, iterations=args.iterations
          )
      else:  # closing
          logger.info("Applying closing...")
          image_smoothed_data = scipy.ndimage.binary_closing(
              image_smoothed_data, footprint, iterations=args.iterations
          )
  
      # apply additional hole closing step
      logger.info("Closing holes...")
      image_smoothed_data = scipy.ndimage.binary_fill_holes(
          image_smoothed_data
      )
  
      # save resulting mas
      save(image_smoothed_data, args.output, image_header, args.force)
  
      logger.info("Successfully terminated.")
  
file_path: medpy/bin/medpy_morphology.py
imports: import argparse
  import logging
  import scipy.ndimage
  from medpy.core import Logger
  from medpy.io import load, save
label_desc: Use image node_id 1 for calling a global function with example usage: main() without return types