-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDoG.py
More file actions
40 lines (34 loc) · 1.61 KB
/
DoG.py
File metadata and controls
40 lines (34 loc) · 1.61 KB
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 1 09:22:38 2020
@author: rajiv
"""
import numpy as np
from skimage.filters import difference_of_gaussians
from PIL import Image
def DoG(image_name, Test= False, perceptron = False):
train_path = "/home/rajiv/Documents/lectures/BIC/project_conv_sdnn/datasets/TrainingSet/Face/"
test_path = "/home/rajiv/Documents/lectures/BIC/project_conv_sdnn/datasets/TestingSet/faces_labeled/"
perceptron_path = "/home/rajiv/Documents/lectures/BIC/project_conv_sdnn/datasets/TrainingSet/faces_labeled/"
if Test:
image = Image.open(test_path + image_name)
image = np.array(image.resize((400,400), Image.BILINEAR))
filtered_image = difference_of_gaussians(image, 1.5)
filtered_image = np.expand_dims(filtered_image, axis = 0)
filtered_image = np.expand_dims(filtered_image, axis = 0)
return filtered_image
elif perceptron:
image = Image.open(perceptron_path + image_name)
image = np.array(image.resize((400,400), Image.BILINEAR))
filtered_image = difference_of_gaussians(image, 1.5)
filtered_image = np.expand_dims(filtered_image, axis = 0)
filtered_image = np.expand_dims(filtered_image, axis = 0)
return filtered_image
else:
image = Image.open(train_path+image_name)
image = np.array(image.resize((400,400), Image.BILINEAR))
filtered_image = difference_of_gaussians(image, 1.5)
filtered_image = np.expand_dims(filtered_image, axis = 0)
filtered_image = np.expand_dims(filtered_image, axis = 0)
return filtered_image