mirror of
https://github.com/qurator-spk/eynollah.git
synced 2025-09-17 21:29:56 +02:00
utils: introduce box2rect and box2slice
This commit is contained in:
parent
d3566e55ef
commit
892ff41e38
1 changed files with 11 additions and 2 deletions
|
@ -1,3 +1,4 @@
|
|||
from typing import Tuple
|
||||
import time
|
||||
import math
|
||||
|
||||
|
@ -298,9 +299,17 @@ def return_x_start_end_mothers_childs_and_type_of_reading_order(
|
|||
x_end_with_child_without_mother,
|
||||
new_main_sep_y)
|
||||
|
||||
def box2rect(box: Tuple[int, int, int, int]) -> Tuple[int, int, int, int]:
|
||||
return (box[1], box[1] + box[3],
|
||||
box[0], box[0] + box[2])
|
||||
|
||||
def box2slice(box: Tuple[int, int, int, int]) -> Tuple[slice, slice]:
|
||||
return (slice(box[1], box[1] + box[3]),
|
||||
slice(box[0], box[0] + box[2]))
|
||||
|
||||
def crop_image_inside_box(box, img_org_copy):
|
||||
image_box = img_org_copy[box[1] : box[1] + box[3], box[0] : box[0] + box[2]]
|
||||
return image_box, [box[1], box[1] + box[3], box[0], box[0] + box[2]]
|
||||
image_box = img_org_copy[box2slice(box)]
|
||||
return image_box, box2rect(box)
|
||||
|
||||
def otsu_copy_binary(img):
|
||||
img_r = np.zeros((img.shape[0], img.shape[1], 3))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue