#!/usr/bin/env python # coding: utf-8 # In[1]: import numpy as np import cv2 as cv # In[2]: bgrimg = cv.imread('reflections.jpg') # In[3]: hsvimg = np.empty(bgrimg.shape, np.uint16) # In[4]: bgrimg.shape # In[5]: 320 * 900 # In[6]: hist = np.zeros((5,9), np.uint32) # In[7]: hist.shape # In[8]: hist = hist.transpose() # In[9]: hist.shape # In[10]: hist = hist.transpose() # In[11]: hist.shape # In[12]: hist2 = hist.flatten() # In[13]: hist2.shape # In[16]: help(np.reshape) # In[17]: hist3 = np.reshape(hist, (45,)) # In[18]: hist3.shape # In[19]: hist3 # In[20]: hist2 # In[21]: hist # In[22]: hist = np.array([60,40,55,46,120]) # In[23]: hist # In[24]: sum(hist) # In[25]: 60/321 # In[26]: 40/321 # In[27]: histnorm = hist / sum(hist) # In[28]: histnorm # In[29]: sum(histnorm) # In[30]: hist2 = np.array([0.1,0.2,0.5,0.2,0]) # In[31]: histnorm # In[32]: hist2 # In[33]: histnorm - hist2 # In[34]: abs(histnorm - hist2) # In[35]: sum(abs(histnorm - hist2)) # L1 distance between the 2 hists # In[36]: histnorm - hist2 # In[37]: pow(2,5) # In[38]: pow(histnorm - hist2, 2) # In[39]: 0.08691589* 0.08691589 # In[40]: sum(pow(histnorm - hist2, 2)) # In[41]: import math # In[42]: math.sqrt(2) # In[43]: math.sqrt(sum(pow(histnorm - hist2, 2))) # L2 distance between the 2 hists # In[ ]: