def main(): input_dir = '/home/heathkh/Desktop/tide_export/pos_jpeg/tide_v00/starbucks_logo/*' filenames = glob.glob(input_dir) width = 200 height = 200 avg_image = None for index, file in enumerate(filenames): input_image = Image.open(file) input_image = input_image.convert("RGB") # accumulate average resized_image = input_image.resize((width, height), Image.NEAREST) # use nearest neighbour if not avg_image: avg_image = resized_image print avg_image.size print resized_image.size #print resized_image alpha = 1.0/(index+1.0) avg_image = ImageChops.blend(avg_image, resized_image, alpha) print alpha if index == 2: break pix = numpy.array(avg_image) print pix avg_image.show()
def process(self, base): yield 'Desaturate...', base lay1 = colors.convert_to_luminosity(base) yield 'Invert...', lay1 lay1 = ImageChops.invert(lay1) yield 'Smoth...', lay1 lay1 = lay1.filter(ImageFilter.BLUR) yield 'Merge...', lay1 lay2 = base.copy() lay2 = ImageChops.blend(lay1, lay2, 0.75) yield 'Mege softlight...', lay2 image = base.copy() image = layers.merge_layers_soft_light(image, lay2, 0.9) yield 'Done', image
def process(self, image): yield 'Contrast...', image image = ImageEnhance.Contrast(image).enhance(1.2) yield 'Colors...', image image = colors.apply_hue_lightness_saturation(image, -0.04, 0, 0.21) yield 'Curves...', image cur_r = list(curves.create_curve([(0, 0), (100, 120), (200, 255), (255, 255)])) cur_g = list(curves.create_curve([(0, 0), (64, 80), (224, 235), (255, 255)])) cur_b = list(curves.create_curve([(0, 35), (255, 235)])) image = curves.apply_curves(image, None, cur_r, cur_g, cur_b) yield 'Colors2...', image image = colors.apply_hue_lightness_saturation(image, -0.02, 0.09, -0.15) yield 'Pink...', image lcolor = image.copy() lcolor = colors.fill_with_color(lcolor, (255, 0, 90)) image = ImageChops.blend(image, lcolor, 0.05) yield 'Done', image
def r7(self): alpha=float(self.var.get()) self.im3=ImageChops.blend(self.im,self.im0,float(alpha/255)) self.tkimage.paste(self.im3)
pygame.init() screen = pygame.display.set_mode(res) pygame.display.set_caption("Predator Vision: by Tech B") fr=False while 1: #check for quit for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() #grab two images if not fr: im1 = cam.getImage() #you will need to wait a sec before taking another image #if not, the screen will remain black and buggy time.sleep(.2) im2 = cam.getImage() #im2-im1 per pixel addx = ImageChops.add(im1,im2,1.3) #diff = ImageChops.difference(im1,im2) #mux = ImageChops.multiply(addx,diff) diff2 = ImageChops.blend(addx, im1,0.9) fr=True im1=diff2 #convert image to pygame type and then display shot = pygame.image.frombuffer(diff2.tostring(), res, "RGB") screen.blit(shot,(0,0)) pygame.display.flip()
def normalize(image): image = image.filter(ImageFilter.BLUR) picture = ImageChops.blend(ImageOps.equalize(image), image, .5) return ImageChops.multiply(picture, picture)
def apply_color(image, color, opacity=1.0): vlayer = Image.new("RGB", image.size, color) if opacity < 1 and opacity > 0: olayer = Image.new("RGB", image.size, (255, 255, 255)) vlayer = ImageChops.blend(olayer, vlayer, opacity) return ImageChops.multiply(image, vlayer)