if __name__ == '__main__': # from sys import argv # if len(argv) < 2: # print("Usage: python %s <image>" % argv[0]) # exit() im_path = '/tfshare/PycharmProjects/canny/valve.png' im = array(Image.open(im_path)) subplot(1, 2, 1) imshow(im) axis('off') title('Original') im = im[:, :, 0] gim = gaussian(im) grim, gphase = gradient(gim) gmax = maximum(grim, gphase) thres = thresholding(gmax) edge = tracking(thres) gray() # subplot(1, 2, 1) # imshow() # axis('off') # title('double') subplot(1, 2, 2) imshow(edge.im) axis('off') title('Edges') show()
thres[i][j] = strong strongs.append((i, j)) elif px >= lo: thres[i][j] = weak return thres, strongs if __name__ == '__main__': from sys import argv if len(argv) < 2: print "Usage: python %s <image>" % argv[0] exit() im = array(Image.open(argv[1])) im = im[:, :, 0] gim = gaussian(im) grim, gphase = gradient(gim) gmax = maximum(grim, gphase) thres = thresholding(gmax) gray() subplot(1, 2, 1) imshow(im) axis('off') title('Original') subplot(1, 2, 2) imshow(thres[0]) axis('off') title('Double thresholding') show()