Skip to content

Commit

Permalink
refinded scaling logic
Browse files Browse the repository at this point in the history
  • Loading branch information
papalotis committed Mar 25, 2024
1 parent 855fa99 commit 6b62715
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drawing_to_fsd_layout/image_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def extract_track_edges(

image = image.copy()

for i in range(10):
for i in range(20):
for s in np.linspace(2, 5, 20):
image_canny = canny(image, sigma=s).astype(float)
m = image_canny.mean()
Expand All @@ -193,10 +193,11 @@ def extract_track_edges(
# other
edge_pixels = np.argwhere(image_canny > 0.01)

if len(edge_pixels) < 6000:
if len(edge_pixels) < 10000:
st.write(i, len(edge_pixels))
break
# st.write("Too many edge pixels, trying again with lower resolution")
image = rescale(image, 0.8)
image = rescale(image, 0.95)

# st.write(f"Found {len(edge_pixels)} of pixels as edges")
else:
Expand All @@ -205,6 +206,9 @@ def extract_track_edges(
)
st.stop()

if show_steps:
st.image(image, caption="Rescaled image")

dist = cdist(edge_pixels, edge_pixels)
adj = dist < 2
adj[np.eye(len(adj), len(adj), dtype=bool)] = 0
Expand Down

0 comments on commit 6b62715

Please sign in to comment.