-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCLAHE & CLAHE with LAB format
58 lines (39 loc) · 1.6 KB
/
CLAHE & CLAHE with LAB format
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# BGR to Gray Scale
img_array = cv2.imread(os.path.join(path, img))
image_bw = cv2.cvtColor(img_array, cv2.COLOR_BGR2GRAY)
# The declaration of CLAHE
# clipLimit -> Threshold for contrast limiting
clahe = cv2.createCLAHE(clipLimit = 5.0, tileGridSize=(16, 16))
final_img = clahe.apply(image_bw) + 0
cv2.imshow("CLAHE image", final_img)
plt.imshow(final_img)
cv2.waitKey(0)
cv2.destroyAllWindows()
#BGR to LAB
#image = cv2.imread("C://AiHints//apple.jpg")
#imread is use to read an image from a location
#img_array = cv2.imread(os.path.join(path, img))
img_array = cv2.imread("E:\FYP\Extra\DATASETS//25_left.jpeg")
lab_image = cv2.cvtColor(img_array, cv2.COLOR_BGR2LAB)
cv2.imshow("Original Image", img_array)
cv2.imshow("LAB Image", lab_image)
cv2.waitKey(0)
cv2.destroyAllWindows()
#CLAHE on LAB
#def histogram_equalization(img):
#img_array = cv2.imread(os.path.join(path, img))
img_array = cv2.imread("E:\FYP\Extra\DATA//25_left.jpeg")
lab = cv2.cvtColor(img_array, cv2.COLOR_BGR2Lab)
# -----Splitting the LAB image to different channels-------------------------
l, a, b = cv2.split(lab)
# -----Applying CLAHE to L-channel-------------------------------------------
clahe = cv2.createCLAHE(clipLimit=5.0, tileGridSize=(32, 32))
cl = clahe.apply(l)
# -----Merge the CLAHE enhanced L-channel with the a and b channel-----------
limg = cv2.merge((cl, a, b))
# -----Converting image from LAB Color model to RGB model--------------------
final = cv2.cvtColor(limg, cv2.COLOR_LAB2BGR)
cv2.imshow("Original Image", img_array)
cv2.imshow("LAB Image", final)
cv2.waitKey(0)
cv2.destroyAllWindows()