import os, sys #The program begins here #provisorial name resetexpo.py # It adapts the grey tones of an image to those of another image recorded of the same object #Particularly images taken with traditional electron microscope photographic device use exposimeters that can vary their settings from one image to another # Provided under GPL licence # Author Alessio Papini, Department of Plant Biology University of Florence Italy, Via La Pira, 4 Firenze, mail alpapiniATunifi.it print('It adapts the grey tones of an image to those of another image recorded of the same object. You must check one same pixel in the two images and check the difference in grey tone and report the difference') print('supported formats bmp, jpg, tif') print('The images must be of the same dimensions (widthxheight) and in frame one with the other') # It explains what the program does i2=raw_input('Write the name of the image of which You need to adjust the grey scale (with its path to directory if different from the current working directory): ') # It gets the names of the image deltapixval=input('Write the difference in grey tone between the second and the first image -the second should be more obscure- (with its path to directory if different from the current working directory), it should be an integer number: ') i3=raw_input('Write the name of the new version of the image with the grey scale adjusted (with its path to directory if different from the current working directory): ') import Image im2 = Image.open(i2) # it loads the image x, y = im2.size # width and height for the two nested cycle needed to go through the image: the pixel position will be in a(x,y) #ora inizio i due cicli annidati lo esterno con la width e lo interno con la heighth della immagine im5=Image.new("L",(x,y)) for i in range (x): for j in range (y): b=im2.getpixel((i,j)) im5.putpixel((i,j),(b-deltapixval)) im5.save(i3) print('grey scale of the figure readapted to requested grey scale ')