num_bins_color = 5 plt.subplot(1, 2, 2) hist_rg = histogram_module.rg_hist(img_color.astype('double'), num_bins_color) plt.bar(np.array(range(1, hist_rg.size + 1)), hist_rg) plt.tight_layout() #Compose and test dxdy histograms (histogram_module.dxdy_hist) plt.figure(5) plt.subplot(1, 2, 1) plt.imshow(img_color) num_bins_dxdy = 10 plt.subplot(1, 2, 2) hist_dxdy = histogram_module.dxdy_hist(img_gray, num_bins_dxdy) plt.bar(np.array(range(1, hist_dxdy.size + 1)), hist_dxdy) plt.tight_layout() # %% ## Distance functions (Question 2.c) image_files1 = ['./model/obj1__0.png'] image_files2 = ['./model/obj91__0.png', './model/obj94__0.png'] plt.figure() plt.subplot(1, 3, 1) plt.imshow(np.array(Image.open(image_files1[0])), vmin=0, vmax=255) plt.title(image_files1[0]) plt.subplot(1, 3, 2) plt.imshow(np.array(Image.open(image_files2[0])), vmin=0, vmax=255)
plt.subplot(1, 2, 1) plt.imshow(img_color) num_bins_rg = 5 plt.subplot(1, 2, 2) hist_rgb1 = histogram_module.rg_hist(img_color.astype('double'), num_bins_rg) plt.bar(np.array(range(1, hist_rgb1.size + 1)), hist_rgb1) plt.show() plt.figure() plt.subplot(1, 2, 1) plt.imshow(img_color) num_bins_rg = 5 plt.subplot(1, 2, 2) hist_rgb1 = histogram_module.dxdy_hist(img_gray.astype('double'), num_bins_rg) plt.bar(np.array(range(1, hist_rgb1.size + 1)), hist_rgb1) plt.show() # distance functions (Question 2.c) image_files1 = ['./model/obj1__0.png'] image_files2 = ['./model/obj91__0.png', './model/obj94__0.png'] plt.figure() plt.subplot(1, 3, 1) plt.imshow(np.array(Image.open(image_files1[0])), vmin=0, vmax=255) plt.title(image_files1[0]) plt.subplot(1, 3, 2) plt.imshow(np.array(Image.open(image_files2[0])), vmin=0, vmax=255) plt.title(image_files2[0])