Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image
- image = Image.open("16x16y.jpg")
- shifted_image = Image.open("shifted_16x16y.jpg")
- X, Y = 16, 16
- value = {"RED": 0, "GREEN": 0, "BLUE": 0}
- shifted_value = {"SHIFTED_RED": 0, "SHIFTED_GREEN": 0, "SHIFTED_BLUE": 0}
- for x in range(1, X - 2):
- for y in range(1, Y - 2):
- pixelRGB_00 = image.getpixel((x, y))
- pixelRGB_01 = image.getpixel((x, y - 1))
- pixelRGB_10 = image.getpixel((x - 1, y))
- pixelRGB_11 = image.getpixel((x - 1, y - 1))
- r00, g00, b00 = pixelRGB_00
- r01, g01, b01 = pixelRGB_01
- r10, g10, b10 = pixelRGB_10
- r11, g11, b11 = pixelRGB_11
- domain_RED = r00 + r01 + r10 + r11
- domain_GREEN = g00 + g01 + g10 + g11
- domain_BLUE = b00 + b01 + b10 + b11
- value["RED"] = domain_RED
- value["GREEN"] = domain_GREEN
- value["BLUE"] = domain_BLUE
- r00, r01, r10, r11, g00, g01, g10, g11, b00, b01, b10, b11 = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- for shifted_x in range(0, X - 1):
- for shifted_y in range(0, Y - 1):
- shifted_pixelRGB_00 = shifted_image.getpixel((shifted_x, shifted_y))
- shifted_pixelRGB_01 = shifted_image.getpixel((shifted_x, shifted_y - 1))
- shifted_pixelRGB_10 = shifted_image.getpixel((shifted_x - 1, shifted_y))
- shifted_pixelRGB_11 = shifted_image.getpixel((shifted_x - 1, shifted_y - 1))
- r00, g00, b00 = shifted_pixelRGB_00
- r01, g01, b01 = shifted_pixelRGB_01
- r10, g10, b10 = shifted_pixelRGB_10
- r11, g11, b11 = shifted_pixelRGB_11
- shifted_domain_RED = r00 + r01 + r10 + r11
- shifted_domain_GREEN = g00 + g01 + g10 + g11
- shifted_domain_BLUE = b00 + b01 + b10 + b11
- shifted_value["SHIFTED_RED"] = shifted_domain_RED
- shifted_value["SHIFTED_GREEN"] = shifted_domain_GREEN
- shifted_value["SHIFTED_BLUE"] = shifted_domain_BLUE
- print(str(value), str(shifted_value))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement