-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathExudates.py
51 lines (39 loc) · 1.45 KB
/
Exudates.py
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
import numpy as np
import cv2
#from matplotlib import pyplot as plt
class ExtractExudates:
jpegImg = 0
grayImg = 0
curImg = 0
def setImage(self, img):
self.jpegImg = img
self.curImg = np.array(img) ##Convert jpegFile to numpy array (Required for CV2)
def getImage(self):
return self.curImg
def greenComp(self):
###Extracting Green Component
gcImg = self.curImg[:,:,1]
self.curImg = gcImg
def applyCLAHE(self):
#Applying Contrast Limited Adaptive Histogram Equalization (CLAHE)
clahe = cv2.createCLAHE()
clImg = clahe.apply(self.curImg)
self.curImg = clImg
# create a CLAHE object (Arguments are optional).
#clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8,8))
#claheImg = clahe.apply(clImg)
#cv2.imwrite('clahe_2.jpg',claheImg)
def applyDilation(self):
#Creating Structurig Element
strEl = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(6,6))
#Dilation
dilateImg = cv2.dilate(self.curImg, strEl)
self.curImg = dilateImg
def applyThreshold(self):
#Thresholding with Complement/Inverse
retValue, threshImg = cv2.threshold(self.curImg, 220, 220, cv2.THRESH_BINARY)
self.curImg = threshImg
def applyMedianFilter(self):
#Median Filtering
medianImg = cv2.medianBlur(self.curImg,5)
self.curImg = medianImg