--- /dev/null
+import Image, ImageMath
+import im_debug
+import sys
+
+im = Image.open('./image.jpg')
+im_debug.show(im, 'Original image')
+
+im_l = im.convert('L')
+im_debug.show(im_l, 'ITU-R 601-2 luma transform')
+
+im_rgb = im.convert('L', (float(1)/3, float(1)/3, float(1)/3, 0))
+im_debug.show(im_rgb, '(R+G+B)/3 transform')
+
+s1, s2 = im.size
+im2 = Image.new('L', (s1 * 2, s2))
+im2.paste(im_l, (0, 0, s1, s2))
+im2.paste(im_rgb, (s1, 0, 2*s1, s2))
+im_debug.show(im2, 'Both transforms side by side')
+
+im_debug.show(ImageMath.eval("convert(abs(a - b)*5, 'L')", a=im_l, b=im_rgb), 'Difference')
--- /dev/null
+import pygame
+import Image
+
+def show(image, caption=''):
+ if image.mode != 'RGB':
+ image = image.convert('RGB')
+ pygame.init()
+ if caption:
+ caption = "Imago: " + caption
+ else:
+ caption = "Imago"
+ pygame.display.set_caption(caption)
+ pygame.display.set_mode(image.size)
+ main_surface = pygame.display.get_surface()
+ picture = pygame.image.frombuffer(image.tostring(), image.size, image.mode)
+ main_surface.blit(picture, (0, 0))
+ pygame.display.update()
+ while True:
+ events = pygame.event.get()
+ for event in events:
+ if event.type == pygame.QUIT or event.type == pygame.KEYDOWN:
+ pygame.quit()
+ return