Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2018
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import cv2
  3. import pdb
  4.  
  5. testimg = cv2.imread('C:/Users/EPIERSO/Docs/testsimmages/stitch1.jpg',cv2.IMREAD_COLOR)
  6. testimghsv = cv2.cvtColor(img,cv2.COLOR_BGR2HSV)
  7. refimg = cv2.imread('C:/Users/EPIERSO/Docs/testsimmages/stitch4.jpg',cv2.IMREAD_COLOR)
  8. refimghsv = cv2.cvtColor(img,cv2.COLOR_BGR2HSV)
  9.  
  10. hbins,sbins = 30,32
  11. histref = cv2.calcHist([testimghsv],[0,1],histSize =[hbins,sbins],mask = None,ranges=[0,180,0,256])
  12. histtest = cv2.calcHist([refimghsv],[0,1],histSize =[hbins,sbins],mask = None,ranges=[0,180,0,256])
  13.  
  14. signref = np.zeros((hbins*sbins,3),dtype=np.float32)
  15. signtest = np.zeros((hbins*sbins,3),dtype=np.float32)
  16.  
  17. for h in range(hbins):
  18.     for s in range(sbins):
  19.         bin = histref[h,s]
  20.         signref[h*sbins+s,0] = bin
  21.         signref[h*sbins+s,1] = h
  22.         signref[h*sbins+s,2] = s
  23.  
  24.         bin = hist2[h,s]
  25.         signtest[h*sbins+s,0] = bin
  26.         signtest[h*sbins+s,1] = h
  27.         signtest[h*sbins+s,2] = s
  28.  
  29. emd = cv2.EMD(sign1.astype(np.float32),sign2.astype(np.float32),cv2.DIST_L2)
  30. print(emd)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement