#NEWLINE# def canny( im , threshold1 = 40.0 , threshold2 = 100.0 , aperture_size = 3 , sigma = None ) : #NEWLINE# #INDENT# '\n    void cvCanny( const CvArr* image, CvArr* edges, double threshold1, double threshold2, int aperture_size=3 );\n    ' #NEWLINE# gray = im . asOpenCVBW ( ) #NEWLINE# edges = cv . CreateImage ( cv . GetSize ( gray ) , 8 , 1 ) #NEWLINE# if ( sigma != None ) : #NEWLINE# #INDENT# cv . Smooth ( gray , gray , cv . CV_GAUSSIAN , ( ( int ( ( sigma + 1 ) ) * 4 ) + 1 ) , ( ( int ( ( sigma + 1 ) ) * 4 ) + 1 ) , sigma , sigma ) #NEWLINE# #UNINDENT# if ( threshold1 < threshold2 ) : #NEWLINE# #INDENT# ( threshold1 , threshold2 ) = ( threshold2 , threshold1 ) #NEWLINE# #UNINDENT# cv . Canny ( gray , edges , threshold1 , threshold2 , aperture_size ) #NEWLINE# return pv . Image ( edges )