import PIL
from PIL import Image
from PIL import ImageDraw, ImageFont
from PIL import ImageEnhance
from PIL import ImageColor
# read image and convert to RGB
image=Image.open("readonly/msi_recruitment.gif")
image=image.convert('RGB')
images=[]
img = Image.new("RGB",(800,530),"Black")
enhancer=ImageEnhance.Brightness(img)
for i in range(0, 10):
images.append(enhancer.enhance(i/10))
font = ImageFont.truetype("readonly/fanwood-webfont.ttf", 75)
def re(img1,img2,channel, r=1,g=1,b=1 ):
for i in range(img2.width):
for j in range(img2.height):
img1.putpixel((i,j),(int(r*(img2.load()[i,j][0])),int(g*(img2.load()[i,j][1])),int(b*(img2.load()[i,j][2]))))
draw = ImageDraw.Draw(img1)
draw.text((0,470),"Channel {} intensity {}".format(channel, min(r,g,b)),"white", font)
return img1
dens = [0.1,0.5,0.9]
for i in range(3):
re(images[i],image,0,dens[i])
re(images[i+3],image,1,1,dens[i])
re(images[i+6],image,2,1,1,dens[i])
first_image = images[0]
contact_sheet=PIL.Image.new(first_image.mode, (first_image.width*3,first_image.height*3))
x=0
y=0
#-------------------------------------------------
for img in images:
# Lets paste the current image into the contact sheet
contact_sheet.paste(img, (x, y) )
# Now we update our X position. If it is going to be the width of the image, then we set it to 0
# and update Y as well to point to the next "line" of the contact sheet.
if x+first_image.width == contact_sheet.width:
x=0
y=y+first_image.height
else:
x=x+first_image.width
# resize and display the contact sheet
contact_sheet = contact_sheet.resize((int(contact_sheet.width/2),int(contact_sheet.height/2) ))
#display(image)
display(contact_sheet)
print("Hello")
import PIL
from PIL import Image
from PIL import ImageEnhance
from PIL import ImageColor
from PIL import ImageFont
from PIL import ImageDraw
# read image and convert to RGB
image=Image.open("readonly/msi_recruitment.gif")
image=image.convert('RGB')
images=[]
lables=[]
# build a list of 9 images with different tones
for i in range(3):
for j in [0.1,0.5,0.9]:
bandwise=image.split()
new_im_band=bandwise[i].point(lambda x:x*j)
bandwise[i].paste(new_im_band)
new_image=Image.merge(image.mode, bandwise)
lables.append("channel {} intensity {}".format(i,j))
images.append(new_image)
# getting the text files
fonts=ImageFont.truetype("readonly/fanwood-webfont.ttf",size=75)
print(lables)
# create a contact sheet from different brightnesses
first_image=images[0]
contact_sheet=PIL.Image.new(first_image.mode, (first_image.width*3,first_image.height*3+250))
x=0
y=0
draw=ImageDraw.Draw(contact_sheet)
i=0
for img in images:
# Lets paste the current image into the contact sheet
contact_sheet.paste(img, (x, y) )
draw.text((x,y+first_image.height+5), lables[i], font=fonts)
i=i+1
# Now we update X position. If it is going to be the width of the image, then we set it to 0
# and update Y as well to point to the next "line" of the contact sheet.
if x+first_image.width == contact_sheet.width:
x=0
y=y+first_image.height+85
else:
x=x+first_image.width
# resize and display the contact sheet
contact_sheet = contact_sheet.resize((int(contact_sheet.width/2),int(contact_sheet.height/2) ))
display(contact_sheet)