# FOURCOLOR.py # Version 20, 17 January 2016 # (c) 2016 by Andrew J. Campbell # # Process 4-color temperatures during laser heating import Tkinter as tk import tkFileDialog from PIL import Image, ImageTk import math import numpy as np import matplotlib.pyplot as pyplot import os # Function Definitions # def convertTIF(im) : # converts 16-bit TIFF image to 8-bit global photo immax = max(list(im.getdata())) im8 = im.point(lambda i: i*(255./immax)) # should be 1./255. for unscaled image photo = ImageTk.PhotoImage(im8) return photo def drawROIs() : # draws ROI circles r = int(roisize.get()) roi1e = w.create_oval(int(roi1ex.get())-r, int(roi1ey.get())-r, int(roi1ex.get())+r, int(roi1ey.get())+r, outline="yellow") roi2e = w.create_oval(int(roi2ex.get())-r, int(roi2ey.get())-r, int(roi2ex.get())+r, int(roi2ey.get())+r, outline="yellow") roi3e = w.create_oval(int(roi3ex.get())-r, int(roi3ey.get())-r, int(roi3ex.get())+r, int(roi3ey.get())+r, outline="yellow") roi4e = w.create_oval(int(roi4ex.get())-r, int(roi4ey.get())-r, int(roi4ex.get())+r, int(roi4ey.get())+r, outline="yellow") roi1w = w.create_oval(int(roi1wx.get())-r, int(roi1wy.get())-r, int(roi1wx.get())+r, int(roi1wy.get())+r, outline="yellow") roi2w = w.create_oval(int(roi2wx.get())-r, int(roi2wy.get())-r, int(roi2wx.get())+r, int(roi2wy.get())+r, outline="yellow") roi3w = w.create_oval(int(roi3wx.get())-r, int(roi3wy.get())-r, int(roi3wx.get())+r, int(roi3wy.get())+r, outline="yellow") roi4w = w.create_oval(int(roi4wx.get())-r, int(roi4wy.get())-r, int(roi4wx.get())+r, int(roi4wy.get())+r, outline="yellow") def tweakROIs(event) : if eastT.get() : calcTatROI() else : refreshW() def refreshW() : # refresh window global photo w.delete("ALL") w.grid(row=7, column=0, columnspan=6, padx=10, pady=10) if activefile.get() == "" : dataimage = Image.new("RGB", (765, 510), "gray") photo=ImageTk.PhotoImage(dataimage) w.create_image(0, 0, image=photo, anchor="nw") else : dataimage = Image.open(activefile.get()) photo = convertTIF(dataimage) w.create_image(0, 0, image=photo, anchor="nw") drawROIs() w.create_text(50, 100, text=eastT.get(), fill="yellow", font=28) w.create_text(50, 410, text=westT.get(), fill="yellow", font=28) w.update() def chooseFolder() : name = tkFileDialog.askdirectory(parent=window, initialdir=activefolder.get(), title='Select a directory') activefolder.set(name) def chooseFile() : name = tkFileDialog.askopenfilename(parent=window, initialdir=activefolder.get(), title='Select a file') activefile.set(name) refreshW() def chooseBackground() : name = tkFileDialog.askopenfilename(parent=window, initialdir=activefolder.get(), title='Select a background file') backgroundfile.set(name) def chooseCalibration() : name = tkFileDialog.askopenfilename(parent=window, initialdir=activefolder.get(), title='Select a calibration file') calibrationfile.set(name) def loadConfigs() : try : z = np.loadtxt("config.four", dtype='str') activefolder.set(z[0]) activefile.set(z[1]) activebkgd.set(z[2]) calibrationfile.set(z[3]) calibrationbkgd.set(z[4]) roisize.set(z[5]) roi1ex.set(z[6]) roi2ex.set(z[7]) roi3ex.set(z[8]) roi4ex.set(z[9]) roi1ey.set(z[10]) roi2ey.set(z[11]) roi3ey.set(z[12]) roi4ey.set(z[13]) roi1wx.set(z[14]) roi2wx.set(z[15]) roi3wx.set(z[16]) roi4wx.set(z[17]) roi1wy.set(z[18]) roi2wy.set(z[19]) roi3wy.set(z[20]) roi4wy.set(z[21]) except: return def saveConfigs() : z = [] z.append(activefolder.get()) z.append(activefile.get()) z.append(activebkgd.get()) z.append(calibrationfile.get()) z.append(calibrationbkgd.get()) z.append(roisize.get()) z.append(roi1ex.get()) z.append(roi2ex.get()) z.append(roi3ex.get()) z.append(roi4ex.get()) z.append(roi1ey.get()) z.append(roi2ey.get()) z.append(roi3ey.get()) z.append(roi4ey.get()) z.append(roi1wx.get()) z.append(roi2wx.get()) z.append(roi3wx.get()) z.append(roi4wx.get()) z.append(roi1wy.get()) z.append(roi2wy.get()) z.append(roi3wy.get()) z.append(roi4wy.get()) np.savetxt("config.four", z, fmt='%s') def moveROIgroup(which, where) : adjust = 0 if (where=="left" or where=="up") : adjust = -1 if (where=="right" or where=="down") : adjust = 1 if (which=="east" and (where=="left" or where=="right")) : new = int(roi1ex.get())+adjust roi1ex.set(new) new = int(roi2ex.get())+adjust roi2ex.set(new) new = int(roi3ex.get())+adjust roi3ex.set(new) new = int(roi4ex.get())+adjust roi4ex.set(new) if (which=="east" and (where=="up" or where=="down")) : new = int(roi1ey.get())+adjust roi1ey.set(new) new = int(roi2ey.get())+adjust roi2ey.set(new) new = int(roi3ey.get())+adjust roi3ey.set(new) new = int(roi4ey.get())+adjust roi4ey.set(new) if (which=="west" and (where=="left" or where=="right")) : new = int(roi1wx.get())+adjust roi1wx.set(new) new = int(roi2wx.get())+adjust roi2wx.set(new) new = int(roi3wx.get())+adjust roi3wx.set(new) new = int(roi4wx.get())+adjust roi4wx.set(new) if (which=="west" and (where=="up" or where=="down")) : new = int(roi1wy.get())+adjust roi1wy.set(new) new = int(roi2wy.get())+adjust roi2wy.set(new) new = int(roi3wy.get())+adjust roi3wy.set(new) new = int(roi4wy.get())+adjust roi4wy.set(new) tweakROIs(0) def setROIs() : # opens window to adjust ROIs winROI = tk.Toplevel(window) winROI.config(padx=10, pady=10) winROI.title("ROIs") pad = 2 sizeLabel = tk.Label(winROI, text="ROI size") sizeLabel.grid(row=0, column=0) sizeSpinbox = tk.Spinbox(winROI, from_=1, to=80, width=3, justify="right", textvariable=roisize) sizeSpinbox.grid(row=0, column=1, padx=pad, pady=pad) eastLabel = tk.Label(winROI, text="East ROIs:") eastLabel.grid(row=1, column=0) eastXlabel = tk.Label(winROI, text="X") eastXlabel.grid(row=2, column=0) roi1exBox = tk.Spinbox(winROI, from_=45, to=145, width=3, justify="right", textvariable=roi1ex) roi1exBox.grid(row=2, column=1, padx=pad, pady=pad) roi2exBox = tk.Spinbox(winROI, from_=237, to=337, width=3, justify="right", textvariable=roi2ex) roi2exBox.grid(row=2, column=2, padx=pad, pady=pad) roi3exBox = tk.Spinbox(winROI, from_=428, to=528, width=3, justify="right", textvariable=roi3ex) roi3exBox.grid(row=2, column=3, padx=pad, pady=pad) roi4exBox = tk.Spinbox(winROI, from_=600, to=720, width=3, justify="right", textvariable=roi4ex) roi4exBox.grid(row=2, column=4, padx=pad, pady=pad) eastroileftbutton = tk.Button(winROI, text="left", command= lambda: moveROIgroup("east", "left")) eastroileftbutton.grid(row=2, column=5, padx=pad, pady=pad) eastroirightbutton = tk.Button(winROI, text="right", command= lambda: moveROIgroup("east", "right")) eastroirightbutton.grid(row=2, column=6, padx=pad, pady=pad) eastYlabel = tk.Label(winROI, text="Y") eastYlabel.grid(row=3, column=0) roi1eyBox = tk.Spinbox(winROI, from_=78, to=300, width=3, justify="right", textvariable=roi1ey) roi1eyBox.grid(row=3, column=1, padx=pad, pady=pad) roi2eyBox = tk.Spinbox(winROI, from_=78, to=300, width=3, justify="right", textvariable=roi2ey) roi2eyBox.grid(row=3, column=2, padx=pad, pady=pad) roi3eyBox = tk.Spinbox(winROI, from_=78, to=300, width=3, justify="right", textvariable=roi3ey) roi3eyBox.grid(row=3, column=3, padx=pad, pady=pad) roi4eyBox = tk.Spinbox(winROI, from_=78, to=300, width=3, justify="right", textvariable=roi4ey) roi4eyBox.grid(row=3, column=4, padx=pad, pady=pad) eastroiupbutton = tk.Button(winROI, text="up", command= lambda: moveROIgroup("east", "up")) eastroiupbutton.grid(row=3, column=5, padx=pad, pady=pad) eastroidownbutton = tk.Button(winROI, text="down", command= lambda: moveROIgroup("east", "down")) eastroidownbutton.grid(row=3, column=6, padx=pad, pady=pad) westLabel = tk.Label(winROI, text="West ROIs:") westLabel.grid(row=4, column=0) westXlabel = tk.Label(winROI, text="X") westXlabel.grid(row=5, column=0) roi1wxBox = tk.Spinbox(winROI, from_=45, to=145, width=3, justify="right", textvariable=roi1wx) roi1wxBox.grid(row=5, column=1, padx=pad, pady=pad) roi2wxBox = tk.Spinbox(winROI, from_=237, to=337, width=3, justify="right", textvariable=roi2wx) roi2wxBox.grid(row=5, column=2, padx=pad, pady=pad) roi3wxBox = tk.Spinbox(winROI, from_=428, to=528, width=3, justify="right", textvariable=roi3wx) roi3wxBox.grid(row=5, column=3, padx=pad, pady=pad) roi4wxBox = tk.Spinbox(winROI, from_=620, to=720, width=3, justify="right", textvariable=roi4wx) roi4wxBox.grid(row=5, column=4, padx=pad, pady=pad) westroileftbutton = tk.Button(winROI, text="left", command= lambda: moveROIgroup("west", "left")) westroileftbutton.grid(row=5, column=5, padx=pad, pady=pad) westroirightbutton = tk.Button(winROI, text="right", command= lambda: moveROIgroup("west", "right")) westroirightbutton.grid(row=5, column=6, padx=pad, pady=pad) westYlabel = tk.Label(winROI, text="Y") westYlabel.grid(row=6, column=0) roi1wyBox = tk.Spinbox(winROI, from_=332, to=432, width=3, justify="right", textvariable=roi1wy) roi1wyBox.grid(row=6, column=1, padx=pad, pady=pad) roi2wyBox = tk.Spinbox(winROI, from_=332, to=432, width=3, justify="right", textvariable=roi2wy) roi2wyBox.grid(row=6, column=2, padx=pad, pady=pad) roi3wyBox = tk.Spinbox(winROI, from_=332, to=432, width=3, justify="right", textvariable=roi3wy) roi3wyBox.grid(row=6, column=3, padx=pad, pady=pad) roi4wyBox = tk.Spinbox(winROI, from_=332, to=432, width=3, justify="right", textvariable=roi4wy) roi4wyBox.grid(row=6, column=4, padx=pad, pady=pad) westroiupbutton = tk.Button(winROI, text="up", command= lambda: moveROIgroup("west", "up")) westroiupbutton.grid(row=6, column=5, padx=pad, pady=pad) westroidownbutton = tk.Button(winROI, text="down", command= lambda: moveROIgroup("west", "down")) westroidownbutton.grid(row=6, column=6, padx=pad, pady=pad) winROI.bind("", tweakROIs) winROI.mainloop() def loadROIfile() : roifile = tkFileDialog.askopenfilename(parent=window, initialdir=activefolder.get(), title='Select ROI file', filetypes = [("ROI","*.roi")]) z = np.loadtxt(roifile, dtype='str') roisize.set(z[0]) roi1ex.set(z[1]) roi2ex.set(z[2]) roi3ex.set(z[3]) roi4ex.set(z[4]) roi1ey.set(z[5]) roi2ey.set(z[6]) roi3ey.set(z[7]) roi4ey.set(z[8]) roi1wx.set(z[9]) roi2wx.set(z[10]) roi3wx.set(z[11]) roi4wx.set(z[12]) roi1wy.set(z[13]) roi2wy.set(z[14]) roi3wy.set(z[15]) roi4wy.set(z[16]) refreshW() def saveROIfile() : roifile = tkFileDialog.asksaveasfilename(parent=window, initialdir=activefolder.get(), title='Save ROI file', initialfile=".roi") z = [] z.append(roisize.get()) z.append(roi1ex.get()) z.append(roi2ex.get()) z.append(roi3ex.get()) z.append(roi4ex.get()) z.append(roi1ey.get()) z.append(roi2ey.get()) z.append(roi3ey.get()) z.append(roi4ey.get()) z.append(roi1wx.get()) z.append(roi2wx.get()) z.append(roi3wx.get()) z.append(roi4wx.get()) z.append(roi1wy.get()) z.append(roi2wy.get()) z.append(roi3wy.get()) z.append(roi4wy.get()) np.savetxt(roifile, z, fmt='%s') def calcROIavgs(imra, roix, roiy) : r = int(roisize.get()) n = 0 roisum = [0., 0., 0., 0.] for i in range(-r, r+1) : for j in range(-r, r+1) : if (i**2+j**2 < r**2) : n = n+1 for k in range(4) : roisum[k] = roisum[k] + imra[roiy[k]+i, roix[k]+j] return np.divide(roisum, n) def calcTatROI() : roiex = [int(roi1ex.get()), int(roi2ex.get()), int(roi3ex.get()), int(roi4ex.get())] roiey = [int(roi1ey.get()), int(roi2ey.get()), int(roi3ey.get()), int(roi4ey.get())] roiwx = [int(roi1wx.get()), int(roi2wx.get()), int(roi3wx.get()), int(roi4wx.get())] roiwy = [int(roi1wy.get()), int(roi2wy.get()), int(roi3wy.get()), int(roi4wy.get())] dataarray = pyplot.imread(activefile.get()) # backarray = pyplot.imread(backgroundfile.get()) calarray = pyplot.imread(calibrationfile.get()) datae = calcROIavgs(dataarray, roiex, roiey) dataw = calcROIavgs(dataarray, roiwx, roiwy) backe = 0. #calcROIavgs(backarray, roiex, roiey) backw = 0. #calcROIavgs(backarray, roiwx, roiwy) cale = calcROIavgs(calarray, roiex, roiey) calw = calcROIavgs(calarray, roiwx, roiwy) scalede = nme *1 scaledw = nmw *1 ye = nme *1 yw = nmw *1 xe = nme *1 xw = nmw *1 for i in range(4) : scalede[i] = (datae[i]-int(activebkgd.get())) / (cale[i]-int(calibrationbkgd.get())) * lampe[i] scaledw[i] = (dataw[i]-int(activebkgd.get())) / (calw[i]-int(calibrationbkgd.get())) * lampw[i] ye[i] = np.log(scalede[i]*nme[i]**5) yw[i] = np.log(scaledw[i]*nmw[i]**5) xe[i] = 1./nme[i] xw[i] = 1./nmw[i] fite = np.polyfit(xe, ye, 1) fitw = np.polyfit(xw, yw, 1) te = -14388000./fite[0] tw = -14388000./fitw[0] wiencorrectione = (1.182*(te/1000.)-1.813)**3.5 wiencorrectionw = (1.182*(tw/1000.)-1.813)**3.5 eastT.set(int(te + wiencorrectione)) westT.set(int(tw + wiencorrectionw)) refreshW() def autoProcessTemperatures() : # read files in activefolder, pick next-to-last one, calculate T from it. while autoprocess.get() : mapButton.config(state='disabled') temperaturesButton.config(state='disabled') fileList = os.listdir(activefolder.get()) filterHiddens(fileList) fileList.sort() if (len(fileList) > 1) : index = len(fileList)-2 activefile.set(activefolder.get() + '/' + fileList[index]) else : activefile.set(activefolder.get() + '/' + fileList[0]) window.after(1000, calcTatROI()) mapButton.config(state='active') temperaturesButton.config(state='active') def mapT() : # Produces T maps over specified areas # Read data d = int(mapsize.get()) datara = pyplot.imread(activefile.get()) calra = pyplot.imread(calibrationfile.get()) roiex = [int(roi1ex.get()), int(roi2ex.get()), int(roi3ex.get()), int(roi4ex.get())] roiey = [int(roi1ey.get()), int(roi2ey.get()), int(roi3ey.get()), int(roi4ey.get())] roiwx = [int(roi1wx.get()), int(roi2wx.get()), int(roi3wx.get()), int(roi4wx.get())] roiwy = [int(roi1wy.get()), int(roi2wy.get()), int(roi3wy.get()), int(roi4wy.get())] # Set up calculation areae = np.zeros((2*d+1, 2*d+1, 4)) areaw = np.zeros((2*d+1, 2*d+1, 4)) cale = np.zeros((2*d+1, 2*d+1, 4)) calw = np.zeros((2*d+1, 2*d+1, 4)) scalede = areae *1 scaledw = areae *1 ye = areae *1 yw = areae *1 xe = nme *1 xw = nmw *1 for k in range(4) : xe[k] = 1./nme[k] xw[k] = 1./nmw[k] mape = areae[:,:,0] *1 mapw = areae[:,:,0] *1 # Fill image subareas for i in range(2*d+1) : for j in range(2*d+1) : for k in range(4) : areae[i,j,k] = datara[roiey[k]+i-d, roiex[k]+j-d] areaw[i,j,k] = datara[roiwy[k]+i-d, roiwx[k]+j-d] cale[i,j,k] = calra[roiey[k]+i-d, roiex[k]+j-d] calw[i,j,k] = calra[roiwy[k]+i-d, roiwx[k]+j-d] # Loop over each position, calculate T for i in range(2*d+1) : for j in range(2*d+1) : if min(areae[i,j,:]) < 3*int(activebkgd.get()) : mape[i,j] = 0 else : for k in range(4) : scalede[i,j,k] = (areae[i,j,k]-int(activebkgd.get())) / (cale[i,j,k]-int(calibrationbkgd.get())) * lampe[k] ye[i,j,k] = np.log(scalede[i,j,k]*nme[k]**5) fite = np.polyfit(xe, ye[i,j,:], 1) te = -14388000./fite[0] wiencorrectione = (1.182*(te/1000.)-1.813)**3.5 mape[i,j] = int(te + wiencorrectione) if min(areaw[i,j,:]) < 3*int(activebkgd.get()) : mapw[i,j] = 0 else : for k in range(4) : scaledw[i,j,k] = (areaw[i,j,k]-int(activebkgd.get())) / (calw[i,j,k]-int(calibrationbkgd.get())) * lampw[k] yw[i,j,k] = np.log(scaledw[i,j,k]*nmw[k]**5) fitw = np.polyfit(xw, yw[i,j,:], 1) tw = -14388000./fitw[0] wiencorrectionw = (1.182*(tw/1000.)-1.813)**3.5 mapw[i,j] = int(tw + wiencorrectionw) return mape, mapw # Output to text file # np.savetxt("eastTmap.txt", mape, fmt='%i') # np.savetxt("westTmap.txt", mapw, fmt='%i') def showTmaps() : def readTe(event) : yy = round(int(event.y) * 2 * int(mapsize.get()) / 200.) xx = round(int(event.x) * 2 * int(mapsize.get()) / 200.) localT.set(int(mape[yy, xx])) def readTw(event) : yy = round(int(event.y) * 2 * int(mapsize.get()) / 200.) xx = round(int(event.x) * 2 * int(mapsize.get()) / 200.) localT.set(int(mapw[yy, xx])) winTmaps = tk.Toplevel(window) winTmaps.config(padx=10, pady=10) winTmaps.title("Temperature maps") maps = mapT() mape = np.asarray(maps[0]) mapw = np.asarray(maps[1]) imge = Image.fromarray(np.rint(np.multiply(mape,255./3000.))) imgw = Image.fromarray(np.rint(np.multiply(mapw,255./3000.))) imge = imge.resize((200, 200), Image.BILINEAR) imgw = imgw.resize((200, 200), Image.BILINEAR) eastimage = ImageTk.PhotoImage(imge) westimage = ImageTk.PhotoImage(imgw) eastmap = tk.Canvas(winTmaps, width=200, height=200) westmap = tk.Canvas(winTmaps, width=200, height=200) eastmap.create_image(0, 0, image=eastimage, anchor="nw") westmap.create_image(0, 0, image=westimage, anchor="nw") eastmap.grid(row=0, column=0, padx=10, pady=10) westmap.grid(row=0, column=1, padx=10, pady=10) localT = tk.StringVar() localT.set("") localTEntry = tk.Entry(winTmaps, textvariable=localT, justify="right", width=6, bg=window.cget('bg'), borderwidth=0) localTEntry.grid(row=1, column=0, padx=10, sticky="W") eastmap.bind("", readTe) westmap.bind("", readTw) winTmaps.mainloop() def filterHiddens(files) : for i in files : if (i[0] != '.') : yield i def readpixel(event) : datara = pyplot.imread(activefile.get()) pixelvalue.set(datara[event.y, event.x]) # # End Function Definitions # Begin Main Window # window = tk.Tk() window.title("Four Color Temperature") window.config(padx=10, pady=10) # Initialize i/o variables activefolder = tk.StringVar() activefolder.set("") activefile = tk.StringVar() activefile.set("") backgroundfile = tk.StringVar() backgroundfile.set("") calibrationfile = tk.StringVar() calibrationfile.set("") activebkgd = tk.StringVar() activebkgd.set(0) calibrationbkgd = tk.StringVar() calibrationbkgd.set(0) autoprocess = tk.BooleanVar() autoprocess.set(0) roisize = tk.StringVar() roisize.set(5) roi1ex = tk.StringVar() roi1ex.set(95) roi2ex = tk.StringVar() roi2ex.set(287) roi3ex = tk.StringVar() roi3ex.set(478) roi4ex = tk.StringVar() roi4ex.set(670) roi1ey = tk.StringVar() roi1ey.set(200) roi2ey = tk.StringVar() roi2ey.set(200) roi3ey = tk.StringVar() roi3ey.set(200) roi4ey = tk.StringVar() roi4ey.set(200) roi1wx = tk.StringVar() roi1wx.set(95) roi2wx = tk.StringVar() roi2wx.set(287) roi3wx = tk.StringVar() roi3wx.set(478) roi4wx = tk.StringVar() roi4wx.set(670) roi1wy = tk.StringVar() roi1wy.set(382) roi2wy = tk.StringVar() roi2wy.set(382) roi3wy = tk.StringVar() roi3wy.set(382) roi4wy = tk.StringVar() roi4wy.set(382) loadConfigs() # Initialize temperature parameters nme = [671.6, 751.9, 801.6, 850.] nmw = [850., 780., 700., 650.] lampe = nme *1 lampw = nmw *1 for i in range(4) : lampe[i] = nme[i]**-5 *math.exp(41.726+(-4857.744/nme[i])) *(0.8139+433.911/nme[i]-309143.63/(nme[i]**2)+78393885.5/(nme[i]**3)-7574000000/(nme[i]**5)) lampw[i] = nmw[i]**-5 *math.exp(41.726+(-4857.744/nmw[i])) *(0.8139+433.911/nmw[i]-309143.63/(nmw[i]**2)+78393885.5/(nmw[i]**3)-7574000000/(nmw[i]**5)) mapsize = tk.StringVar() mapsize.set(30) eastT = tk.StringVar() eastT.set("") westT = tk.StringVar() westT.set("") # Set data folder, files #folderLabel = tk.Label(window, text="Directory") folderEntry = tk.Entry(window, textvariable=activefolder, width=40, justify="right") folderButton = tk.Button(window, text="Directory", command=chooseFolder, width=10) #folderLabel.grid(row=0, column=0, sticky="E") folderEntry.grid(row=0, column=1) folderButton.grid(row=0, column=0, sticky="E") #filenameLabel = tk.Label(window,text="Filename") filenameEntry = tk.Entry(window, textvariable=activefile, width=40, justify="right") filenameButton = tk.Button(window, text="Image file", command=chooseFile, width=10) #filenameLabel.grid(row=1, column=0, sticky="E") filenameEntry.grid(row=1, column=1) filenameButton.grid(row=1, column=0, sticky="E") backgroundLabel = tk.Label(window,text="-", width=1) backgroundEntry = tk.Entry(window, textvariable=activebkgd, width=5, justify="right") #backgroundButton = tk.Button(window, text="Browse", command=chooseBackground) backgroundLabel.grid(row=1, column=2, sticky="W") backgroundEntry.grid(row=1, column=3, sticky="W") #backgroundButton.grid(row=2, column=2, sticky="W") #calibrationLabel = tk.Label(window,text="Calibration") calibrationEntry = tk.Entry(window, textvariable=calibrationfile, width=40, justify="right") calibrationButton = tk.Button(window, text="Calibration", command=chooseCalibration, width=10) #calibrationLabel.grid(row=3, column=0, sticky="E") calibrationEntry.grid(row=2, column=1) calibrationButton.grid(row=2, column=0, sticky="E") calibbackLabel = tk.Label(window, text="-", width=1) calibbackEntry = tk.Entry(window, textvariable=calibrationbkgd, width=5, justify="right") calibbackLabel.grid(row=2, column=2, sticky="W") calibbackEntry.grid(row=2, column=3, sticky="W") # Controls for ROIs and temperature calculation loadROIbutton = tk.Button(window, text="Load ROIs", width=10, command=loadROIfile) saveROIbutton = tk.Button(window, text="Save ROIs", width=10, command=saveROIfile) roiButton = tk.Button(window, text="Adjust ROIs", width=10, command=setROIs) loadROIbutton.grid(row=0, column=5) saveROIbutton.grid(row=1, column=5) roiButton.grid(row=2, column=5) temperaturesButton = tk.Button(window, text="Calculate T", command=calcTatROI, width=10) temperaturesButton.grid(row=5, column=1, rowspan=2) #eastTentry = tk.Entry(window, textvariable=eastT, width=8, justify="right") #westTentry = tk.Entry(window, textvariable=westT, width=8, justify="right") #eastTentry.grid(row=5, column=1, padx=14, sticky="W") #westTentry.grid(row=6, column=1, padx=14, sticky="W") # Start/stop button for auto-processing temperature calculation autoprocessButton = tk.Checkbutton(window, text="Auto process", variable=autoprocess, command=autoProcessTemperatures) autoprocessButton.grid(row=5, column=3, rowspan=2) # Button for producing temperature maps mapButton = tk.Button(window, text="Map T", command=showTmaps, width=10) mapButton.grid(row=5, column=5, rowspan=2) # Canvas for image and ROIs w = tk.Canvas(window, width=765, height=510) pixelvalue = tk.StringVar() pixelvalue.set(0) w.bind("", readpixel) w.grid(row=7, column=0, columnspan=6, padx=10, pady=10) pixelvalueEntry = tk.Entry(window, textvariable=pixelvalue, justify="right", width=6, bg=window.cget('bg'), borderwidth=0) pixelvalueEntry.grid(row=8, column=0, padx=10, sticky="W") refreshW() window.mainloop() saveConfigs() mapT() # Wishlist: # Autoscale button. Show saturated pixels? # Zoom button. # Improve background subtraction. # T map window. Calculate T map based on ROI positions. # Data logging. Write to file, and display on graph. # Clean up code, especially list of ROIs. Should array and loop through them. # For Windows version: change file/directory name conventions.