if x == 0: I = ISpatial tree = treeSpatial else: I = INonSpatial tree = treeNonSpatial for cell in cells_testWeWant: cellr = cell['id'][1] cellc = cell['id'][2] cellNeighbors = adj_test[cell['id']] DTOutput = SDT.sdt_predict(tree, cell, cellNeighbors, theta) if DTOutput == cell['class']:#Correct result if DTOutput == 'null': # TN pass else : # TP I = drawSquare(I,cellr,cellc,green) else: # incorrect result if DTOutput == 'null': #FN I = drawSquare(I,cellr,cellc,yellow) else : # FP I = drawSquare(I,cellr,cellc,red) if x == 0: ISpatial = I else: INonSpatial = I IFinal = np.concatenate((INonSpatial,ISpatial), axis = 1) m.imsave(outputname,IFinal) counter += 1 print counter
eventClass = e dataset = d print eventClass,dataset headers,matches = SOLARGenImageList.image_event_matches(dataset=dataset,waves = ['0171']) S_train,S_test, = read_data(e,n,d,w,b) cells, adj = S_train cells2, adj2 = S_test print 'matches calculated' counter = 0 total = len(matches.keys()) for x in sorted(matches.keys()): # for each image paramsFilename = x[0] imageFilename = paramsFilename[:-4]+'_th.png' I = m.imread(imageFilename) outputname = os.path.join(outputFolder,e,os.path.basename(imageFilename)[:-4]+'_'+e+'.png') cellsWeWant = [x for x in cells if x['id'][3][0] == paramsFilename] for cell in cellsWeWant: cellr = cell['id'][1] cellc = cell['id'][2] I = drawSquare(I,cellr,cellc,colordict[e] if cell['class'] != 'null' else black ) # null training cells are colored black, non-nulls are colored according to their class cellsWeWant2 = [x for x in cells2 if x['id'][3][0] == paramsFilename] for cell in cellsWeWant2: cellr = cell['id'][1] cellc = cell['id'][2] I = drawSquare(I,cellr,cellc,cyan) #color the test cells cyan m.imsave(outputname,I) counter += 1 print counter, '/', total