Python code for Ghent image processor

 

Code

#from __future__ import print_function

import os,sys

#import Image

from PIL import Image

import io

jpgfile = Image.open("/Users/markciotola1/Programs/python/Image_Processing/ghent_area_google_sat_01.png")

# print jpgfile.bits, jpgfile.size, jpgfile.format

myname = "R-B"

print(jpgfile.format, jpgfile.size, jpgfile.mode)

pix = jpgfile.load()

print jpgfile.size

jpgfile.show()

print "analysis"

offset = 0.0

myoff = 0.0

redstart = 0

#bluestart = 0

mypic = Image.new("RGB", [jpgfile.width,jpgfile.height], color=0)

for y in range(0, jpgfile.height): #each pixel has coordinates

    for x in range(0, jpgfile.width):

        mycalc = pix[x,y][0] + pix[x,y][2]

        mypic.putpixel( (x, y), ( mycalc, mycalc, mycalc  ))  # jpgfile.pix[x,y]

mypic.show()

print y

print myoff

mypic.save("/Users/markciotola1/Programs/python/Image_Processing/mypic1"+str(myname)+".jpg")

# REFERENCE

# https://pillow.readthedocs.org/en/latest/reference/Image.html#image-processing

# http://pythontips.com/2013/07/30/20-python-libraries-you-cant-live-without/