Commit
•
0c196bb
1
Parent(s):
a99d36a
added crop
Browse files- configs/augmentations.json +38 -0
- src/control.py +11 -2
configs/augmentations.json
CHANGED
@@ -441,5 +441,43 @@
|
|
441 |
"defaults": "image_half_width"
|
442 |
}
|
443 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
444 |
]
|
445 |
}
|
|
|
441 |
"defaults": "image_half_width"
|
442 |
}
|
443 |
}
|
444 |
+
],
|
445 |
+
"Crop": [
|
446 |
+
{
|
447 |
+
"param_name": [
|
448 |
+
"x_min",
|
449 |
+
"x_max"
|
450 |
+
],
|
451 |
+
"type": "min_max",
|
452 |
+
"placeholder": {
|
453 |
+
"limits_list": [
|
454 |
+
0,
|
455 |
+
"image_width"
|
456 |
+
],
|
457 |
+
"defaults_list": [
|
458 |
+
0,
|
459 |
+
"image_half_width"
|
460 |
+
]
|
461 |
+
},
|
462 |
+
"min_diff" : 1
|
463 |
+
},
|
464 |
+
{
|
465 |
+
"param_name": [
|
466 |
+
"y_min",
|
467 |
+
"y_max"
|
468 |
+
],
|
469 |
+
"type": "min_max",
|
470 |
+
"placeholder": {
|
471 |
+
"limits_list": [
|
472 |
+
0,
|
473 |
+
"image_height"
|
474 |
+
],
|
475 |
+
"defaults_list": [
|
476 |
+
0,
|
477 |
+
"image_half_height"
|
478 |
+
]
|
479 |
+
},
|
480 |
+
"min_diff" : 1
|
481 |
+
}
|
482 |
]
|
483 |
}
|
src/control.py
CHANGED
@@ -28,9 +28,18 @@ def select_several_ints(
|
|
28 |
return tuple(result)
|
29 |
|
30 |
|
31 |
-
def select_min_max(param_name, limits_list, defaults_list, **kwargs):
|
32 |
assert len(param_name) == 2
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
|
36 |
def select_RGB(param_name, **kwargs):
|
|
|
28 |
return tuple(result)
|
29 |
|
30 |
|
31 |
+
def select_min_max(param_name, limits_list, defaults_list, min_diff=0, **kwargs):
|
32 |
assert len(param_name) == 2
|
33 |
+
result = list(select_int_interval(" & ".join(param_name), limits_list, defaults_list))
|
34 |
+
if result[1] - result[0] < min_diff:
|
35 |
+
diff = min_diff - result[1] + result[0]
|
36 |
+
if result[1] + diff <= limits_list[1]:
|
37 |
+
result[1] = result[1] + diff
|
38 |
+
elif result[0] - diff >= limits_list[0]:
|
39 |
+
result[0] = result[0] - diff
|
40 |
+
else:
|
41 |
+
result = limits_list
|
42 |
+
return tuple(result)
|
43 |
|
44 |
|
45 |
def select_RGB(param_name, **kwargs):
|