Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. def part4():
  2.  
  3. f, axarr = plt.subplots(2, 3)
  4. frostfogSrc = cv.imread("a2images/frostfog.png", 0)
  5.  
  6. frostfogEH=cv.equalizeHist(frostfogSrc)
  7. axarr[0,0].set_title("equalizeHist")
  8. axarr[0, 0].imshow(frostfogEH,cmap='gray')
  9. histN, b, l = axarr[0,1].hist(frostfogEH.ravel(), histSize, histRange, True, label="normal",color='blue')
  10. histC = axarr[0, 2].hist(frostfogEH.ravel(), histSize, histRange, True, None, True, label="cumulative",color='green')
  11. axarr[0, 1].bar(b[:-1], histN * (1/max(histN)), np.diff(b),color='b')
  12.  
  13. mn,mx,mmnl,mxl=cv.minMaxLoc(frostfogSrc)
  14. print(mn,mx,mmnl,mxl)
  15.  
  16. x,y=frostfogSrc.shape
  17. frostfogCS=frostfogSrc.copy()
  18. for i in range(0,x):
  19. for j in range(0,y):
  20. frostfogCS[i,j]= ((frostfogCS[i,j]-mn)/(mx-mn))*255
  21.  
  22. axarr[1, 0].set_title("constant stretching")
  23. axarr[1, 0].imshow(frostfogCS, cmap='gray')
  24.  
  25. histN, b, l = axarr[1, 1].hist(frostfogCS.ravel(), histSize, histRange, True, label="normal", color='blue')
  26. histC = axarr[1, 2].hist(frostfogCS.ravel(), histSize, histRange, True, None, True, label="cumulative",
  27. color='green')
  28. axarr[1, 1].bar(b[:-1], histN * (1 / max(histN)), np.diff(b), color='b')
  29.  
  30.  
  31. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement