def erodeAndDilate(self, processed): self.newStep() options = self.options # contr = ImageEnhance.Contrast(self.processed) # contr = contr.enhance(2) # processed = cv.fromarray(numpy.array(contr)) _processed = cv.fromarray(numpy.array(processed)) # res = cv.CreateImage(cv.GetSize(processed), 8, 1) # cv.CvtColor(processed, res, cv.CV_BGR2GRAY) ImageHelpers.dilateImage(_processed, 1) ImageHelpers.erodeImage(_processed, 1) processed = Image.fromarray(numpy.uint8(_processed)) if options.verbose: processed.save(options.output_dir + '/{}-erode-and-dilate.png'.format(self.getStep())) return processed
#!/usr/bin/python # -*- coding: iso-8859-15 -*- from PIL import Image from operator import itemgetter import os, hashlib, time, re, numpy, string, math import helpers as ImageHelpers import core.logger as Logger from scipy import ndimage """ # Use Denoising clean = cv2.fastNlMeansDenoising(numpy.array(im), None, 17, 4, 7) im = Image.fromarray(numpy.uint8(clean)) # Contrast contr = ImageEnhance.Contrast(im) im = contr.enhance(1.3) # Sharpness sharp = ImageEnhance.Sharpness(im) im = sharp.enhance(1.1) # Dilate and Erode image _processed = cv.fromarray(numpy.array(processed)) ImageHelpers.dilateImage(_processed, 1) ImageHelpers.erodeImage(_processed, 1) processed = Image.fromarray(numpy.uint8(_processed)) """