def launchCPU(self): frames_PIL = [ Image.fromstring("RGB", self.pre_video.getSize(), i.tostring()) for i in self.pre_video.getAllFrames() ] for i in xrange(1, len(frames_PIL)): # Diferencia diferencia = DifferenceFilter(frames_PIL[i], frames_PIL[i + 1]) diferencia.Apply(Filter.CPU) tmp = diferencia.fetchResult() # Threshold threshold = ThresholdFilter(tmp, level=20) threshold.Apply(Filter.CPU) tmp2 = threshold.fetchResult() # Erosion erosion = ErosionFilter(tmp2) erosion.Apply(Filter.CPU) post = erosion.fetchResult() # TODO Mergeado en una clase aparte r, g, b = frames_PIL[i + 1].split() tmp = ImageChops.add(r, post) merged = Image.merge("RGB", (tmp, g, b)) self.post_video.appendFrame(merged) print "#", # Terminado, salvamos resultado self.post_video.Save("./out.mpg")
def launchCPU(self): frames_PIL = [Image.fromstring("RGB", self.pre_video.getSize(), i.tostring()) for i in self.pre_video.getAllFrames()] for i in xrange(1, len(frames_PIL)): # Diferencia diferencia = DifferenceFilter(frames_PIL[i], frames_PIL[i + 1]) diferencia.Apply(Filter.CPU) tmp = diferencia.fetchResult() # Threshold threshold = ThresholdFilter(tmp, level=20) threshold.Apply(Filter.CPU) tmp2 = threshold.fetchResult() # Erosion erosion = ErosionFilter(tmp2) erosion.Apply(Filter.CPU) post = erosion.fetchResult() # TODO Mergeado en una clase aparte r, g, b = frames_PIL[i + 1].split() tmp = ImageChops.add(r, post) merged = Image.merge("RGB", (tmp, g, b)) self.post_video.appendFrame(merged) print "#", # Terminado, salvamos resultado self.post_video.Save("./out.mpg")
print 'Usage:', sys.argv[0], '<image1> <image2' sys.exit(1) im1 = Image.open(sys.argv[1]) im2 = Image.open(sys.argv[2]) # Diferencia diferencia = DifferenceFilter(im1, im2) diferencia.Apply(Filter.CPU) tmp = diferencia.fetchResult() tmp.save("diferencia.png", "PNG") # Threshold threshold = ThresholdFilter(tmp, level=20) threshold.Apply(Filter.CPU) tmp2 = threshold.fetchResult() tmp2.save("threshold.png", "PNG") # Erosion erosion = ErosionFilter(tmp2) erosion.Apply(Filter.CPU) post = erosion.fetchResult() post.save("erosion.png", "PNG") # TODO Mergeado en una clase aparte r, g, b = im2.split() tmp = ImageChops.add(r, post) merged = Image.merge("RGB", (tmp, g, b)) merged.save("merged.png", "PNG")