mirror of
https://github.com/qurator-spk/eynollah.git
synced 2025-10-27 07:44:12 +01:00
order_of_regions: filter out-of-image peaks
This commit is contained in:
parent
48761c3e12
commit
c43a825d1d
1 changed files with 7 additions and 6 deletions
|
|
@ -1216,15 +1216,16 @@ def order_of_regions(textline_mask, contours_main, contours_head, y_ref):
|
||||||
peaks_neg, _ = find_peaks(zneg, height=0)
|
peaks_neg, _ = find_peaks(zneg, height=0)
|
||||||
peaks_neg = peaks_neg - 20 - 20
|
peaks_neg = peaks_neg - 20 - 20
|
||||||
|
|
||||||
##plt.plot(z)
|
peaks_neg_new = np.array([0] +
|
||||||
##plt.show()
|
# peaks can be beyond box due to padding and smoothing
|
||||||
cx_main, cy_main = find_center_of_contours(contours_main)
|
[peak for peak in peaks_neg
|
||||||
cx_head, cy_head = find_center_of_contours(contours_head)
|
if 0 < peak and peak < textline_mask.shape[0]] +
|
||||||
|
[textline_mask.shape[0]])
|
||||||
peaks_neg_new = np.append(np.insert(peaks_neg, 0, 0), textline_mask.shape[0])
|
|
||||||
# offset from bbox of mask
|
# offset from bbox of mask
|
||||||
peaks_neg_new += y_ref
|
peaks_neg_new += y_ref
|
||||||
|
|
||||||
|
cx_main, cy_main = find_center_of_contours(contours_main)
|
||||||
|
cx_head, cy_head = find_center_of_contours(contours_head)
|
||||||
# assert not len(cy_main) or np.min(peaks_neg_new) <= np.min(cy_main) and np.max(cy_main) <= np.max(peaks_neg_new)
|
# assert not len(cy_main) or np.min(peaks_neg_new) <= np.min(cy_main) and np.max(cy_main) <= np.max(peaks_neg_new)
|
||||||
# assert not len(cy_head) or np.min(peaks_neg_new) <= np.min(cy_head) and np.max(cy_head) <= np.max(peaks_neg_new)
|
# assert not len(cy_head) or np.min(peaks_neg_new) <= np.min(cy_head) and np.max(cy_head) <= np.max(peaks_neg_new)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue