Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##DATA NEW - WITH LBP
- with open("dataall.csv", "w") as fo:
- fo.write("filename,data,class\n")
- for i in glob.glob("D:\FYPPP\Getah\ORI\*.PNG"):
- print(i)
- label = i.split("-")[1].split(".")[0]
- label = 0 if label == 'S' else 1
- #show original image
- ori = imread(i)
- #change to gray
- im = cv2.imread(i, cv2.IMREAD_GRAYSCALE)
- #contrast
- icon = exposure.rescale_intensity(im, in_range=(np.percentile(im,5), np.percentile(im,20)))
- with warnings.catch_warnings():
- warnings.simplefilter("ignore")
- dt = img_as_ubyte(icon)
- # make image blur
- imed = cv2.medianBlur(icon.astype(np.uint8), 3)
- plt.imshow(imed,cmap=plt.get_cmap('gray') )
- plt.show()
- #LBP
- print("LBP with thresh")
- radius = 3
- n_points = 8 * radius
- lbp = local_binary_pattern(imed, n_points, radius, 'ror')
- plt.imshow(imed,cmap=plt.get_cmap('gray') )
- plt.show()
- data = '-'.join(map(str,lbp.flatten().tolist()))
- fo.write("{},{},{}\n".format(i, data, label))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement