-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
75 lines (56 loc) · 2.42 KB
/
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
# Copyright (C) 2024 Jose Ángel Pérez Garrido
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import argparse
import sys
import os
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.dirname(SCRIPT_DIR))
from src.centroid import *
from src.file import *
from src.symmetry import *
from src.skeleton import *
def get_args():
parser = argparse.ArgumentParser(description="Detects reflection symmetry in shapes using shape signatures")
"""
Data handling
"""
parser.add_argument('--dataset-folder', type=str, default='./images',
help='dataset folder path (default: ./images)')
"""
Other Parameters
"""
parser.add_argument('--centroid-func', choices=["centroid","mass","min_circle"], default="centroid", help='Centroid computation\
function ["centroid","mass","min_circle"] (default: centroid)')
parser.add_argument('--threshold', type=float, default=0.5, help='Threshold\
(default: 0.5)')
return parser.parse_args()
if __name__ == '__main__':
args = get_args()
# Load images
images = load_images(args.dataset_folder)
# Get centroid computation function
if args.centroid_func == "centroid":
centroid_func = find_centroid
elif args.centroid_func == "mass":
centroid_func = find_center_of_mass
elif args.centroid_func == "min_circle":
centroid_func = find_center_of_min_circle
tau = args.threshold # Threshold
# Execution on original images
for image in images:
plt.imshow(image, cmap=plt.cm.gray)
plt.title("Original image")
plt.show()
print("- Image")
mirror = SignatureSymmetry(image, tau, centroid_func=centroid_func)
mirror.run()