Skip to content

Instantly share code, notes, and snippets.

@robintw
Created November 20, 2015 09:32
Show Gist options
  • Save robintw/f676172b934074c39be4 to your computer and use it in GitHub Desktop.
Save robintw/f676172b934074c39be4 to your computer and use it in GitHub Desktop.
import sys
import numpy as np
import gdal
from mycanny import mycanny
input_image = sys.argv[1]
print(input_image)
input_image = gdal.Open(input_image)
input_image = input_image.GetRasterBand(1).ReadAsArray()
print("Got image")
print(np.nanmax(input_image))
print(np.nanmean(input_image))
edges, thresholds = mycanny(input_image, low_threshold=0.7, high_threshold=0.85, mask=np.isfinite(input_image))
print("Using calculated thresholds of: ")
print(thresholds)
print("Found %d edges" % edges[edges > 0].sum())
edges, thresholds = mycanny(input_image, low_threshold=thresholds[0],
high_threshold=thresholds[1], abs_thresh=True, mask=np.isfinite(input_image))
print("Using absolute thresholds of: ")
print(thresholds)
print("Found %d edges" % edges[edges > 0].sum())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment