title: How do I convert multiple pictures, in a folder with ITK color map?
body: <p>Every time I run my program in the terminal it prints out: 
  thumb0496.jpg is not converted
  {} is not converted</p>
  
  <p>Whatever I do it never works... I am new to Python and have installed it via Anaconda along with OpenCV, Pip and ITK. I have only been doing this for 4 days and am stuck. Python is my first language also. Why are my code not working? </p>
  
  <p>In case this code looks similar it is. I had to try out with combining some elements. Unfortunately I cannot find the post again. The code was worse before but I (somehow) fixed it. It is just this (new) piece I can't fix on my own! </p>
  
  <pre><code>import cv2
  import sys
  import itk
  import os,glob
  
  from os import listdir,makedirs
  from os.path import isfile,join
  path = '/Users/admin/Desktop/ff'
  dstpath = '/Users/admin/Desktop/test'
  
  PixelType = itk.UC
  Dimension = 2
  
  ImageType = itk.Image[PixelType, Dimension]
  
  RGBPixelType = itk.RGBPixel[PixelType]
  RGBImageType = itk.Image[RGBPixelType, Dimension]
  
  ColormapType = itk.CustomColormapFunction[PixelType, RGBPixelType]
  colormap = ColormapType.New()
  
  ColormapFilterType = itk.ScalarToRGBColormapImageFilter[ImageType,RGBImageType]
  colormapFilter1 = ColormapFilterType.New()
  
  colormapFilter1.SetInput(reader.GetOutput())
  colormapFilter1.SetColormap(colormap)
  
  WriterType = itk.ImageFileWriter[RGBImageType]
  writer = WriterType.New()
  writer.SetFileName(dstpath)
  writer.SetInput(colormapFilter1.GetOutput())
  
  try:
      makedirs(dstpath)
  except:
      print ("Directory already exist, images will be written in same folder")
  files = [f for f in listdir(path) if isfile(join(path,f))]
  for image in files:
      try:
          reader = ReaderType(os.path.join(path,image))
          map = ColormapFilterType(reader, PixelType, RGBImageType, ImageType)
          dstPath = join(dstpath,image)
          cv2.imwrite(dstPath,map)
      except:
          print ("{} is not converted".format(image))
  for fil in glob.glob("*.jpg"):
      try:
          img = ReaderType(os.path.join(path,fil))
          map_imag = ColormapType(img, PixelType, RGBImageType,ImageType)
          cv2.imwrite(os.path.join(dstpath,fil),map_image)
      except:
          print('{} is not converted')
  </code></pre>