Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python
- # SNToner.py
- # Author: Abdul Fatir
- # E-Mail: abdulfatirs@gmail.com
- from PIL import Image
- # Opening the Raw Image File
- raw_image = Image.open("raw.png")
- WIDTH,HEIGHT = raw_image.size
- # Creating Image objects for Sepia and Negative Images
- sepia_image = Image.new("RGB",(WIDTH,HEIGHT))
- neg_image = Image.new("RGB",(WIDTH,HEIGHT))
- # Loading Pixel Data for all images
- raw_pixels = raw_image.load()
- sepia_pixels = sepia_image.load()
- neg_pixels = neg_image.load()
- for Y in range(HEIGHT):
- for X in range(WIDTH):
- # Getting RGB of each pixel
- R,G,B = raw_pixels[X,Y]
- oR = (R*.393) + (G*.769) + (B*.189)
- oG = (R*.349) + (G*.686) + (B*.168)
- oB = (R*.272) + (G*.534) + (B*.131)
- # Writing pixel data after doing necessary manipulations
- sepia_pixels[X,Y] = (int(oR),int(oG),int(oB))
- neg_pixels[X,Y] = (255-R,255-G,255-B)
- # Saving the images
- sepia_image.save('sepia.png')
- neg_image.save('negative.png')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement