def column_img(uid,fieldid,img_type1,img_type2): import matplotlib.pyplot as plt import cv2 if img_type1=='colormap_farmonaut': img1 = cv2.imread((img_type1+'.jpg')) img2 = cv2.imread((img_type2+'.jpg')) else: img1 = cv2.imread((uid+'/'+img_type1+ '_white'+'.png')) img2 = cv2.imread((uid+'/'+img_type2+'_white' + '.png')) try: img1 = cv2.cvtColor(img1,cv2.COLOR_BGRA2RGBA) img2 = cv2.cvtColor(img2,cv2.COLOR_BGRA2RGBA) except: img1 = cv2.imread((uid+'/'+img_type1+'.png')) img2 = cv2.imread((uid+'/'+img_type2 + '.png')) img1 = cv2.cvtColor(img1,cv2.COLOR_BGRA2RGBA) img2 = cv2.cvtColor(img2,cv2.COLOR_BGRA2RGBA) plt.subplot(1,2,1) plt.imshow(img1) plt.tight_layout() plt.axis('off') if img_type1=='TCI': title = 'True Color Image' plt.title(title) elif img_type1=='TCI_large': title = 'True Color Image' plt.title(title) elif img_type1==(fieldid+'_static_map_large'): title = 'Field and Nearby Region' plt.title(title) elif img_type1 =='colormap_farmonaut': title = '' elif img_type1 =='ndvi': title = 'NDVI (Colormap 1)' plt.title(title) elif img_type1 =='ndvi_piechart': title = '' elif img_type1 =='ndwi': title = 'NDWI (Colormap 1)' plt.title(title) elif img_type1 =='ndwi_piechart': title = '' elif img_type1 =='ndre': title = 'NDRE (Colormap 1)' plt.title(title) elif img_type1 =='ndre_piechart': title = '' elif img_type1 =='vari': title = 'VARI (Colormap 1)' plt.title(title) elif img_type1 =='vari_piechart': title = '' #plt.title(title) else: title = '' plt.subplot(1,2,2) plt.imshow(img2) plt.tight_layout() plt.axis('off') if img_type2=='ETCI': title = 'Enhanced True Color Image' plt.title(title) elif img_type2=='ETCI_large': title = 'Enhanced True Color Image' plt.title(title) elif img_type2==(fieldid+'_static_map'): title = 'Field In Focus' plt.title(title) elif img_type2 =='colormap2': title = '' elif img_type2 =='ndvi_cmap2': title = 'NDVI (Colormap 2)' plt.title(title) elif img_type2 =='ndvi_linegraph': title = '' elif img_type2 =='ndwi_cmap2': title = 'NDWI (Colormap 2)' plt.title(title) elif img_type2 =='ndwi_linegraph': title = '' elif img_type2 =='ndre_cmap2': title = 'NDRE (Colormap 2)' plt.title(title) elif img_type2 =='ndre_linegraph': title = '' elif img_type2 =='vari_cmap2': title = 'VARI (Colormap 2)' plt.title(title) elif img_type2 =='vari_linegraph': title = '' else: title = '' #plt.show() file_name = uid+'/collage'+'_'+img_type1+'_'+img_type2+'.png' if img_type1.find('piechart')>=0: fig = plt.gcf() fig.set_size_inches(12.8,9.6) plt.savefig(file_name) plt.close() img3= cv2.imread(file_name) img3 = img3[200:750,100:1230] cv2.imwrite(file_name,img3) else: plt.savefig(file_name) plt.close() img3= cv2.imread(file_name) #img3 = img3[0:550,:] #cv2.imwrite(file_name,img3)