import matplotlib.pyplot as plt from database import DataBaseLoad import processing import os import numpy as np # 1) Connect to the database mydb_filename = os.path.abspath('../database.db') mydb = DataBaseLoad(mydb_filename) # 2) Define the position-orinetation at which # we want the image rowid = 5000 my_scene = processing.scene(mydb, rowid=rowid) my_apcv = processing.apcv(my_scene, mydb.viewing_directions) my_apcv_sph = processing.tools.cartesian_to_spherical(x=my_apcv[..., 0], y=my_apcv[..., 1], z=my_apcv[..., 2]) elevation = mydb.viewing_directions[..., processing.constants.__spherical_indeces__[ 'elevation']] azimuth = mydb.viewing_directions[..., processing.constants.__spherical_indeces__[ 'azimuth']] f, axarr = plt.subplots(1, 2, figsize=(15, 4)) to_plot_im = my_scene[:, :, :3, 0] to_plot_im -= to_plot_im.min() to_plot_im /= to_plot_im.max() to_plot_im = to_plot_im * 255 to_plot_im = to_plot_im.astype(np.uint8) to_plot_dist = my_scene[:, :, 3, 0] ax = axarr[0] for chan_i, chan_n in enumerate(['R', 'G', 'B']): color = chan_n ax.plot(np.rad2deg(my_apcv_sph[..., chan_i, 1]), np.rad2deg(my_apcv_sph[..., chan_i, 0]), 'o', color=color) ax.imshow(to_plot_im, extent=[np.min(azimuth), np.max(azimuth), np.max(elevation), np.min(elevation)]) ax.invert_yaxis() ax = axarr[1] color = 'k' ax.plot(np.rad2deg(my_apcv_sph[..., 3, 1]), np.rad2deg(my_apcv_sph[..., 3, 0]), 'o', color=color) ax.imshow(to_plot_dist, extent=[np.min(azimuth), np.max(azimuth), np.max(elevation), np.min(elevation)]) ax.invert_yaxis() f.show()