fix(extract): Kartenbeschriftung nicht mehr als Geometrie ausgeben
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0bf2c29061
commit
f3abb5e803
92 files changed
+161
-96
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import numpy as np
|
||||
from leonida.classify import CLASSES, PALETTE, class_shares, classify
|
||||
from leonida.classify import CLASSES, PALETTE, class_shares, classify, drop_map_labels
|
||||
|
||||
def block(color, size=8):
|
||||
return np.full((size, size, 3), color, dtype=np.uint8)
|
||||
@@ -34,3 +34,27 @@ def test_shares_sum_to_one():
|
||||
shares = class_shares(classify(img))
|
||||
assert abs(sum(shares.values()) - 1.0) < 1e-9
|
||||
assert abs(shares["wasser"] - 0.5) < 1e-9
|
||||
|
||||
def test_letter_shaped_island_becomes_water():
|
||||
"""Ein Buchstabe im Wasser ist Beschriftung, keine Stadt: keine natuerlichen Merkmale."""
|
||||
labels = np.full((200, 200), CLASSES["wasser"], dtype=np.uint8)
|
||||
labels[40:60, 40:120] = CLASSES["stadt"] # Querbalken
|
||||
labels[40:120, 40:60] = CLASSES["strasse"] # Laengsbalken -> zusammen ein "L"
|
||||
out = drop_map_labels(labels)
|
||||
assert (out == CLASSES["wasser"]).all()
|
||||
|
||||
def test_real_island_survives():
|
||||
"""Eine Insel mit Gruen und Sand bleibt, auch wenn sie klein und vom Festland getrennt ist."""
|
||||
labels = np.full((200, 200), CLASSES["wasser"], dtype=np.uint8)
|
||||
labels[40:120, 40:120] = CLASSES["stadt"]
|
||||
labels[50:70, 50:70] = CLASSES["gruen"]
|
||||
labels[100:115, 45:115] = CLASSES["sand"]
|
||||
out = drop_map_labels(labels)
|
||||
assert (out[40:120, 40:120] != CLASSES["wasser"]).all()
|
||||
|
||||
def test_mainland_is_never_dropped():
|
||||
"""Die groesste Nicht-Wasser-Komponente bleibt immer, auch voellig ohne Gruen und Sand."""
|
||||
labels = np.full((200, 200), CLASSES["wasser"], dtype=np.uint8)
|
||||
labels[10:190, 10:100] = CLASSES["stadt"]
|
||||
out = drop_map_labels(labels)
|
||||
assert (out[10:190, 10:100] == CLASSES["stadt"]).all()
|
||||
Reference in new issue
Block a user