title: Remove original image after processing
body: <p>My connected component function takes original image processes it and generates processed images how do i delete original image from folder and keep only processed one.</p>
  
  <pre><code>def run(dirname, img):
      data = img.load()
      width, height = img.size
      output_img = Image.new("RGB", (100, 100))
      Zero=np.zeros(shape=(100, 100), dtype=np.uint8)
  
      for (x, y) in labels:
          component = uf.find(labels[(x, y)])
          labels[(x, y)] = component
          path = 'D:/Python36/Fold/'
          if labels[(x, y)] == 0:
              Zero[y][x] = 255
              Zeroth = Image.fromarray(Zero)
              Zeroth.save(os.path.join(dirname, 'Zero.png'), 'png')
  
  
  def main():
      path = "D:/Python36/Fold/"
      for root, dirs, files in os.walk(path):
          for file_ in files:
              img = Image.open(os.path.join(root, file_))
              img = img.point(lambda p: p &gt; 190 and 255)
              img = img.convert('1')
              (labels, output_img) = run(root, img)
  
  
  if __name__ == "__main__":
      main()
  </code></pre>