Advertisement
Guest User

Untitled

a guest
May 27th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. ##DATA NEW - WITH LBP
  2.  
  3. with open("dataall.csv", "w") as fo:
  4.  
  5. fo.write("filename,data,class\n")
  6.  
  7. for i in glob.glob("D:\FYPPP\Getah\ORI\*.PNG"):
  8.  
  9. print(i)
  10.  
  11. label = i.split("-")[1].split(".")[0]
  12. label = 0 if label == 'S' else 1
  13.  
  14. #show original image
  15. ori = imread(i)
  16.  
  17. #change to gray
  18. im = cv2.imread(i, cv2.IMREAD_GRAYSCALE)
  19.  
  20. #contrast
  21. icon = exposure.rescale_intensity(im, in_range=(np.percentile(im,5), np.percentile(im,20)))
  22. with warnings.catch_warnings():
  23. warnings.simplefilter("ignore")
  24. dt = img_as_ubyte(icon)
  25.  
  26. # make image blur
  27. imed = cv2.medianBlur(icon.astype(np.uint8), 3)
  28. plt.imshow(imed,cmap=plt.get_cmap('gray') )
  29. plt.show()
  30.  
  31. #LBP
  32. print("LBP with thresh")
  33. radius = 3
  34. n_points = 8 * radius
  35. lbp = local_binary_pattern(imed, n_points, radius, 'ror')
  36. plt.imshow(imed,cmap=plt.get_cmap('gray') )
  37. plt.show()
  38.  
  39. data = '-'.join(map(str,lbp.flatten().tolist()))
  40.  
  41. fo.write("{},{},{}\n".format(i, data, label))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement