-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFCVT_main.py
124 lines (82 loc) · 3.16 KB
/
FCVT_main.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# -*- coding: utf-8 -*-
"""
@author: ChernHong Lim
"""
"""
Main testing
"""
import FCVT as fcvt
"""""""""""""""""""""
Image Acquisition
"""""""""""""""""""""
#Provide setting
sourceDir = 'im_lenna.png'
#Read image
image = fcvt.IA_readSource(sourceDir, True)
"""""""""""""""""""""
Image Preprocessing
"""""""""""""""""""""
#Image resize
imageResize = fcvt.IP_resize(image, 0.5, 0.5, True)
#Convert image to gray scale
imageGray = fcvt.IP_convertGray(image, True)
imageBinary = fcvt.IP_convertBinary(image, True)
#Image Morphological Operation
imageDigit = fcvt.IA_readSource('im_digit.png', True)
imageMorph = fcvt.IP_imageMorph(imageDigit, 'erosion', (3,3), True)
imageMorph = fcvt.IP_imageMorph(imageDigit, 'dilation', (5,5), True)
imageMorph = fcvt.IP_imageMorph(imageDigit, 'opening', (3,3), True)
imageMorph = fcvt.IP_imageMorph(imageDigit, 'closing', (5,5), True)
#Image filtering
imageCameraman = fcvt.IA_readSource('im_cameraman_noise.jpg', True)
imageFiltered = fcvt.IP_imageFilt(imageCameraman, 'average', (10,10), True)
imageFiltered = fcvt.IP_imageFilt(imageCameraman, 'gaussian', (5,5 ), True)
imageFiltered = fcvt.IP_imageFilt(imageCameraman, 'median', (3,3), True)
"""""""""""""""""""""
Feature Extraction
"""""""""""""""""""""
#Color detction
imageMap = fcvt.IA_readSource('im_map.png', True)
#lowerbound = [240,185,120]
#upperbound = [260,205,150]
lowerbound = [120,185,240]
upperbound = [150,205,260]
imageColor = fcvt.FE_colorDetection(imageMap, lowerbound, upperbound, True)
#lowerbound = [100,205,245]
#upperbound = [170,230,265]
lowerbound = [245,205,100]
upperbound = [265,230,170]
imageColor = fcvt.FE_colorDetection(imageMap, lowerbound, upperbound, True)
#lowerbound = [179,220,204]
#upperbound = [199,240,224]
lowerbound = [204,220,179]
upperbound = [224,240,199]
imageColor = fcvt.FE_colorDetection(imageMap, lowerbound, upperbound, True)
#lowerbound = [228,214,235]
#upperbound = [248,254,255]
lowerbound = [235,214,228]
upperbound = [255,254,248]
imageColor = fcvt.FE_colorDetection(imageMap, lowerbound, upperbound, True)
#Edge detection
imageChessboard = fcvt.IA_readSource('im_imageChessboard.png', True)
imageEdge = fcvt.FE_edgeDetection(imageChessboard, True)
#Corner detection
imageCorner = fcvt.FE_cornerDetection(imageChessboard, True)
#Local Binary Pattern (LBP)
imageLBP = fcvt.FE_LBPDetection(image, True)
#Keypoint detection
imageKeyPoint = fcvt.FE_keypointDetection(image, 'SIFT', True)
imageKeyPoint = fcvt.FE_keypointDetection(image, 'SURF', True)
"""""""""""""""""""""
Feature Representation
"""""""""""""""""""""
cluster = fcvt.FE_Clustering(imageKeyPoint[1], 5)
#
descriptor = fcvt.FE_Quantisation(imageKeyPoint[1], cluster[0])
"""""""""""""""""""""
Image classification
"""""""""""""""""""""
Output_crisp = fcvt.Image_Classification('Training', 'Testing', 'SIFT', 'Crisp')
Output_fuzzy = fcvt.Image_Classification('Training', 'Testing2', 'SIFT', 'Fuzzy')
Output_fuzzy = fcvt.Image_Classification('Training', 'Testing', 'LBP', 'Crisp')
Output_fuzzy = fcvt.Image_Classification('Training', 'Testing', 'LBP', 'Fuzzy')