def cannyEdge(I): # convert RGB image to gray color space im_gray = utils.rgb2gray(I) Mag, Magx, Magy, Ori = findDerivatives(im_gray) M = nonMaxSup(Mag, Ori) E = edgeLink(M, Mag, Ori) # only when test passed that can show all results if Test_script(im_gray, E): # visualization results utils.visDerivatives(im_gray, Mag, Magx, Magy) utils.visCannyEdge(I, M, E) plt.show() return E
def cannyEdge(I): # convert RGB image to gray color space im_gray = utils.rgb2gray(I) #im_gray = np.kron([[1, 0] * 4, [1, 0] * 4] * 4, np.ones((10, 10)))*255 Mag, Magx, Magy, Ori = findDerivatives(im_gray) M = nonMaxSup(Mag, Ori) #Image.fromarray(M.astype("uint8")*255).show() E = edgeLink(M, Mag, Ori) # only when test passed that can show all results if Test_script(im_gray, E): # visualization results utils.visDerivatives(im_gray, Mag, Magx, Magy) utils.visCannyEdge(I, M, E) plt.show() return E
def cannyEdge(I, sigma, low_c, high_c, filename): # convert RGB image to gray color space im_gray = utils.rgb2gray(I) Mag, Magx, Magy, Ori = findDerivatives(im_gray, sigma) M = nonMaxSup(Mag, Ori) E = edgeLink(M, Mag, Ori, low_c, high_c) # only when test passed that can show all results if Test_script(im_gray, E): # visualization results utils.visDerivatives(im_gray, Mag, Magx, Magy) utils.visCannyEdge(I, M, E) #name = "%s_%d_%d_%d_.jpeg" % (filename, sigma*10, low_c*10, high_c*10) #plt.savefig(name, bbox_inches='tight', format='jpeg') #plt.close() plt.show() return E
def cannyEdge(I, fname=None): # convert RGB image to gray color space T0 = time.time() im_gray = utils.rgb2gray(I) Mag, Magx, Magy, Ori = findDerivatives(im_gray) print(filename, "(findDerivatives) elapsed time:", time.time() - T0) # print(Mag.shape,Magx.shape,Magy.shape,Ori.shape) M = nonMaxSup(Mag, Ori) print(fname, "(nonMaxSup) elapsed time:", time.time() - T0) E = edgeLink(M, Mag, Ori) print(fname, "(edgeLink) elapsed time:", time.time() - T0) Test_script(im_gray, E) # only when test passed that can show all results # if Test_script(im_gray, E): # # visualization results # utils.visDerivatives(im_gray, Mag, Magx, Magy, fname) # utils.visCannyEdge(I, M, E, fname ) # plt.show() print(filename, "(Test_script) elapsed time:", time.time() - T0) return E