Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Udayraj123
GitHub Repository: Udayraj123/OMRChecker
Path: blob/master/src/constants/image_processing.py
262 views
1
"""
2
Constants for image processing operations across OMRChecker.
3
"""
4
5
# General Image Processing
6
DEFAULT_WHITE_COLOR = 255
7
DEFAULT_BLACK_COLOR = 0
8
DEFAULT_NORMALIZE_PARAMS = {
9
"alpha": 0,
10
"beta": 255
11
}
12
DEFAULT_LINE_WIDTH = 2
13
DEFAULT_MARKER_LINE_WIDTH = 4
14
DEFAULT_CONTOUR_COLOR = (0, 255, 0)
15
DEFAULT_CONTOUR_LINE_WIDTH = 2
16
DEFAULT_CONTOUR_FILL_COLOR = (255, 255, 255)
17
DEFAULT_CONTOUR_FILL_WIDTH = 10
18
DEFAULT_BORDER_REMOVE = 5
19
20
DEFAULT_GAUSSIAN_BLUR_PARAMS_MARKER = {
21
"kernel_size": (5, 5),
22
"sigma_x": 0
23
}
24
25
# CropPage constants
26
MIN_PAGE_AREA_THRESHOLD = 80000
27
MAX_COSINE_THRESHOLD = 0.35
28
DEFAULT_GAUSSIAN_BLUR_KERNEL = (3, 3)
29
PAGE_THRESHOLD_PARAMS = {
30
"threshold_value": 200,
31
"max_pixel_value": 255
32
}
33
CANNY_PARAMS = {
34
# lower_threshold: lower bound for Canny edge detection
35
# upper_threshold: upper bound for Canny edge detection
36
"lower_threshold": 185,
37
"upper_threshold": 55,
38
}
39
APPROX_POLY_EPSILON_FACTOR = 0.025
40
41
# CropOnMarkers constants
42
QUADRANT_DIVISION = {
43
"height_factor": 3,
44
"width_factor": 2
45
}
46
MARKER_RECTANGLE_COLOR = (150, 150, 150)
47
ERODE_RECT_COLOR = (50, 50, 50)
48
NORMAL_RECT_COLOR = (155, 155, 155)
49
EROSION_PARAMS = {
50
"kernel_size": (5, 5),
51
"iterations": 5
52
}
53
54
# FeatureBasedAlignment constants
55
DEFAULT_MAX_FEATURES = 500
56
DEFAULT_GOOD_MATCH_PERCENT = 0.15
57
58
# Builtin processor constants
59
DEFAULT_MEDIAN_BLUR_KERNEL_SIZE = 5
60
DEFAULT_GAUSSIAN_BLUR_PARAMS = {
61
"kernel_size": (3, 3),
62
"sigma_x": 0
63
}
64
65
# Summary of recent changes:
66
# - Renamed `CANNY_EDGE_PARAMS` -> `CANNY_PARAMS` and keys
67
# `canny_threshold_min`/`canny_threshold_max` ->
68
# `lower_threshold`/`upper_threshold` for clearer semantics.
69