code: def template_segmentation_image(
      image,
      parameters,
      simulation_time,
      brightness,
      scale_color=True,
      fastlinking=False,
      show_spikes=False,
      ccore_flag=True,
  ):
      image_source = Image.open(image)
      image_size = image_source.size
  
      width = image_size[0]
      height = image_size[1]
  
      stimulus = read_image(image)
      stimulus = rgb2gray(stimulus)
  
      if brightness is not None:
          for pixel_index in range(len(stimulus)):
              if stimulus[pixel_index] < brightness:
                  stimulus[pixel_index] = 1
              else:
                  stimulus[pixel_index] = 0
      else:
          maximum_stimulus = float(max(stimulus))
          minimum_stimulus = float(min(stimulus))
          delta = maximum_stimulus - minimum_stimulus
  
          for pixel_index in range(len(stimulus)):
              if scale_color is True:
                  stimulus[pixel_index] = 1.0 - (
                      (float(stimulus[pixel_index]) - minimum_stimulus)
                      / delta
                  )
              else:
                  stimulus[pixel_index] = (
                      float(stimulus[pixel_index]) / 255
                  )
  
      if parameters is None:
          parameters = pcnn_parameters()
  
          parameters.AF = 0.1
          parameters.AL = 0.1
          parameters.AT = 0.8
          parameters.VF = 1.0
          parameters.VL = 1.0
          parameters.VT = 30.0
          parameters.W = 1.0
          parameters.M = 1.0
  
          parameters.FAST_LINKING = fastlinking
  
      net = pcnn_network(
          len(stimulus),
          parameters,
          conn_type.GRID_EIGHT,
          height=height,
          width=width,
          ccore=ccore_flag,
      )
      output_dynamic = net.simulate(simulation_time, stimulus)
  
      pcnn_visualizer.show_output_dynamic(output_dynamic)
  
      ensembles = output_dynamic.allocate_sync_ensembles()
      draw_image_mask_segments(image, ensembles)
  
      pcnn_visualizer.show_time_signal(output_dynamic)
  
      if show_spikes is True:
          spikes = output_dynamic.allocate_spike_ensembles()
          draw_image_mask_segments(image, spikes)
  
          pcnn_visualizer.animate_spike_ensembles(
              output_dynamic, image_size
          )
  
imports: from PIL import Image
  from pyclustering.utils import read_image, rgb2gray, draw_image_mask_segments
  from pyclustering.nnet.pcnn import pcnn_network, pcnn_parameters, pcnn_visualizer
  from pyclustering.nnet import *
  from pyclustering.samples.definitions import IMAGE_SIMPLE_SAMPLES, IMAGE_MAP_SAMPLES, IMAGE_REAL_SAMPLES
label_desc: Use image node_id 1 for calling a global function with example usage: template_segmentation_image(image, parameters, simulation_time, brightness, scale_color, fastlinking, show_spikes, ccore_flag) without return types