def get_pts_from_sgeom_vague(R, per=np.pi / 3, lwr=40): ''' Get a referenced points from Sgeom object in order to compute the distance between the target and the final curve. In this case, it is from circular wave image ''' r_nb = 200 rough_dict = {'lwr': lwr} my_sgeom = rand_circle(R, 0, 0, r_nb, rough_dict, per) xy_arr = my_sgeom.get_xy()[0] x_arr = xy_arr[:, 0] y_arr = xy_arr[:, 1] tck, _ = spline.build_spline(x_arr, y_arr, per=True, k=3) knots = tck[0] ctrl_pts = np.transpose(tck[1]) deg = tck[2] spl = BSpline_periodic(knots, ctrl_pts, deg, is_periodic=True) return spl(np.linspace(0, 1, 10000))
def create_vague_local(R, threshold=50, per=np.pi / 3): ''' Create a image in which the maximum pixels form a circular wave having a radius R Parameters ---------- R : float Radius of the circle threshold: float, optional Every pixel of which the value is less than this threshold is set to 0 per: float, optional Periodicity of the wave Returns ------- img_xy : RectBivariate object A narray whose values at non-integer coordinates are available thanks to interpolation imsh : ImShape object A object which helps to display the contour and the image ''' img_shape = (512, 512) frame_bounds = [-256, 256, -256, 256] r_nb = 200 rough_dict = {'lwr': 10} my_sgeom = rand_circle(R, 0, 0, r_nb, rough_dict, per) strat = lscad.MountainStrategy() param_dict = {'hmax': 100., 'sigma': (0, 0)} img = fk_img.img_from_sgeom(img_shape, frame_bounds, my_sgeom, z_map_strategy=strat, param_dict=param_dict) img.arr[img.arr < threshold] = 0 x, y = img.arrf.sampling_vectors() img_xy = interpolate.RectBivariateSpline(x, y, np.flipud(img.arr)) gcoll = GeomCollection() gcoll.set_geom(0, my_sgeom) imsh = ImShape(image=img, geom_coll=gcoll) return img_xy, imsh
def create_fluctuation(): img_shape = (512, 512) frame_bounds = [-256, 256, -256, 256] R = 25 r_nb = 150 rough_dict = {'lwr': 10} r_per = np.pi / 3 my_sgeom = rand_circle(R, 0, 0, r_nb, rough_dict, r_per) strat = lscad.MountainStrategy() param_dict = {'hmax': 100., 'sigma': (0, 0)} img = fk_img.img_from_sgeom(img_shape, frame_bounds, my_sgeom, z_map_strategy=strat, param_dict=param_dict) gcoll = GeomCollection() gcoll.set_geom(0, my_sgeom) imsh = ImShape(image=img, geom_coll=gcoll) imsh.plot() plt.show()