#NEWLINE# def generate_synthetic_data( ) : #NEWLINE# #INDENT# ' Synthetic binary data ' #NEWLINE# rs = np . random . RandomState ( 0 ) #NEWLINE# n_pts = 36.0 #NEWLINE# ( x , y ) = np . ogrid [ 0 : l , 0 : l ] #NEWLINE# mask_outer = ( ( ( ( x - ( l / 2 ) ) ** 2 ) + ( ( y - ( l / 2 ) ) ** 2 ) ) < ( ( l / 2 ) ** 2 ) ) #NEWLINE# mask = np . zeros ( ( l , l ) ) #NEWLINE# points = ( l * rs . rand ( 2 , n_pts ) ) #NEWLINE# mask [ ( points [ 0 ] . astype ( np . int ) , points [ 1 ] . astype ( np . int ) ) ] = 1 #NEWLINE# mask = ndimage . gaussian_filter ( mask , sigma = ( l / n_pts ) ) #NEWLINE# res = np . logical_and ( ( mask > mask . mean ( ) ) , y ) #NEWLINE# return ( res - ndimage . binary_erosion ( res ) )