• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

de4fening Nov 13th, 2019 (edited) 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. from PIL import Image
2.
3. image = Image.open("16x16y.jpg")
4. shifted_image = Image.open("shifted_16x16y.jpg")
5.
6. X, Y = 16, 16
7.
8. value = {"RED": 0, "GREEN": 0, "BLUE": 0}
9. shifted_value = {"SHIFTED_RED": 0, "SHIFTED_GREEN": 0, "SHIFTED_BLUE": 0}
10.
11. for x in range(1, X - 2):
12.     for y in range(1, Y - 2):
13.         pixelRGB_00 = image.getpixel((x, y))
14.         pixelRGB_01 = image.getpixel((x, y - 1))
15.         pixelRGB_10 = image.getpixel((x - 1, y))
16.         pixelRGB_11 = image.getpixel((x - 1, y - 1))
17.         r00, g00, b00 = pixelRGB_00
18.         r01, g01, b01 = pixelRGB_01
19.         r10, g10, b10 = pixelRGB_10
20.         r11, g11, b11 = pixelRGB_11
21.         domain_RED = r00 + r01 + r10 + r11
22.         domain_GREEN = g00 + g01 + g10 + g11
23.         domain_BLUE = b00 + b01 + b10 + b11
24.         value["RED"] = domain_RED
25.         value["GREEN"] = domain_GREEN
26.         value["BLUE"] = domain_BLUE
27.
28. r00, r01, r10, r11, g00, g01, g10, g11, b00, b01, b10, b11 = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
29.
30. for shifted_x in range(0, X - 1):
31.     for shifted_y in range(0, Y - 1):
32.         shifted_pixelRGB_00 = shifted_image.getpixel((shifted_x, shifted_y))
33.         shifted_pixelRGB_01 = shifted_image.getpixel((shifted_x, shifted_y - 1))
34.         shifted_pixelRGB_10 = shifted_image.getpixel((shifted_x - 1, shifted_y))
35.         shifted_pixelRGB_11 = shifted_image.getpixel((shifted_x - 1, shifted_y - 1))
36.         r00, g00, b00 = shifted_pixelRGB_00
37.         r01, g01, b01 = shifted_pixelRGB_01
38.         r10, g10, b10 = shifted_pixelRGB_10
39.         r11, g11, b11 = shifted_pixelRGB_11
40.         shifted_domain_RED = r00 + r01 + r10 + r11
41.         shifted_domain_GREEN = g00 + g01 + g10 + g11
42.         shifted_domain_BLUE = b00 + b01 + b10 + b11
43.         shifted_value["SHIFTED_RED"] = shifted_domain_RED
44.         shifted_value["SHIFTED_GREEN"] = shifted_domain_GREEN
45.         shifted_value["SHIFTED_BLUE"] = shifted_domain_BLUE
46.
47. print(str(value), str(shifted_value))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top