Created
May 24, 2013 16:15
-
-
Save ramonesteban/5644605 to your computer and use it in GitHub Desktop.
Obtener los bordes de una imagen usando PyWavelets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, pylab, numpy, Image, pywt | |
def edges(path): | |
im = Image.open(path).convert('L') | |
arr = numpy.fromstring(im.tostring(), numpy.uint8) | |
arr.shape = (im.size[1], im.size[0]) | |
data = pywt.swt2(arr, 'haar', level=3, start_level=0) | |
LL, (LH, HL, HH) = data[2] | |
pylab.imshow(LH, interpolation='nearest', cmap=pylab.cm.gray) | |
pylab.show() | |
def main(): | |
if len(sys.argv) > 1: | |
path = str(sys.argv[1]) | |
edges(path) | |
else: | |
print 'Image file needed' | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment