def SaveOverlayImages(tifStackData,SeedsPyFile,SegmentsDirectory,red=True): # This function is more-or-less just a template right now, has MAJOR issues... r = GTL.LoadFileSequence(SegmentsDirectory, wildcard='*.tif') rgbM = CreateMapPlots(r) for i in range(len(Files)): tifDir,nameTif = os.path.split(Files[i]) mapDir = os.path.join(tifDir,'Maps') overlayDir = os.path.join(tifDir,'Overlay') for j in [mapDir,overlayDir]: if not os.path.exists(j): os.mkdir(j) name = os.path.splitext(nameTif)[0] nameSeedsPy = '_'.join(name.split('_')[:-2])+'_Seeds.py' ### GENERATE MAP PLOT namePng = name+'.png' rgbMi = CreateMapPlot(r[i]) im = Image.fromarray(rgbMi) im.save(os.path.join(mapDir,namePng)) ### NOW GENERATE OVERLAY IMAGE # Grab the frame number from the image name... frameNumber = int(name.split('_')[-1]) # Get the watershed file from the saved tif: watershed = GTL.LoadSingle(Files[i]) # Find and load the correct original array based on the frame number: originalDir = '.../2010FEB09_Edge5/TiffStack' # Put in the right directory here... origFile = FS.getSortedListOfFiles(originalDir)[frameNumber] original = GTL.LoadSingle(origFile) SeedsPyFile = os.path.join(tifDir,nameSeedsPy) overlayIm = CreateOverlay(original,watershed,SeedsPyFile,frameNumber) # Now, save the overlay as a png nameSeedsOutl = name+'SO.png' im = Image.fromarray(overlayIm) im.save(os.path.join(overlayDir,nameSeedsOutl))
def SaveDiffImages(logDir): diffDir = os.path.join(logDir,'Diff') if not os.path.exists(diffDir): os.mkdir(diffDir) Files = FS.getSortedListOfFiles(logDir,'*.tif') frameUpdateList = [] # [time,fn,newVal] for i,f in enumerate(Files): name = os.path.splitext(os.path.split(f)[1])[0] frameNumber = int(name.split('_')[-1]) cur = GTL.LoadSingle(f) final = GTL.LoadSingle(FrameFiles[frameNumber]) d = CreateDiffImage(cur,final) frameUpdateList.append([timeAxis[i],frameNumber,d.astype(int).sum()]) im = Image.fromarray(d*255) im.save(os.path.join(diffDir,name+'.png'))