-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpreposcessing.py
62 lines (50 loc) · 1.92 KB
/
preposcessing.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
52
53
54
55
56
57
58
59
60
61
62
import cv2
from tqdm import tqdm
from loguru import logger
class preprocessing():
"""Manipulate images for Exodus Segmentation
"""
def __init__(self,
dataname,
data,
):
"""Init of the prepocessing classs
Args:
dataname (str): Names of the data set
data (list): List of images to analyze
"""
self.data = data
self.dataname = dataname
self.clahe_result= []
self.denoising_result= []
self.data_length = len(data)
logger.info(f"Class Initialized: {self.__class__}")
def green_ch_splitting_and_clahe(self, img):
"""Splitting into green channel and Normalazing the image
Args:
img (image): 3 channel image in RGB
Returns:
g: 1 channel image in grayscale
"""
(R, G, B) = cv2.split(img)
clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(10,10))
G = clahe.apply(G)
return G
def get_Prepocessing(self):
"""Do the complete process for the full dataset
Returns:
list: of Images applied the Clahe and Denosing
"""
with tqdm(total=self.data_length,desc="Clahe "+self.dataname) as statusbar:
for i in range(0,self.data_length):
self.clahe_result.append(
self.green_ch_splitting_and_clahe(self.data[i])
)
statusbar.update(1)
with tqdm(total=self.data_length,desc="Denosing Image "+self.dataname) as statusbar:
for i in range(0,self.data_length):
self.denoising_result.append(
cv2.fastNlMeansDenoising(self.clahe_result[i],15, 7, 21 )
)
statusbar.update(1)
return self.denoising_result