# Construct the mean shift object from it, including a composite kernel... ms = MeanShift() ms.set_data(data, 'df') ms.set_kernel('composite(2:gaussian,2:fisher(32.0))') ms.set_spatial('kd_tree') ms.set_scale(numpy.array([10.0,5.0,1.0,1.0])) ms.merge_range = 0.05 # Print out information in a convoluted way to test some convoluted features!.. ms2 = MeanShift() ms2.copy_kernel(ms) print 'Kernel:', ms2.get_kernel() del ms2 # For our first trick visualise the data set... img = numpy.zeros((size, size, 3), dtype=numpy.float32) for sample in data: s_x = (size-1) * sample[1] / scale s_y = (size-1) * sample[0] / scale e_x = (size-1) * (sample[1] + angle_len * sample[3]) / scale e_y = (size-1) * (sample[0] + angle_len * sample[2]) / scale for i in xrange(angle_step):
(-1, 1)), numpy.sin(direction).reshape((-1, 1))), axis=1) data.append(block) data = numpy.concatenate(data, axis=0) # Construct the mean shift object from it, including a composite kernel... ms = MeanShift() ms.set_data(data, 'df') ms.set_kernel('composite(2:gaussian,2:fisher(32.0))') ms.set_spatial('kd_tree') ms.set_scale(numpy.array([10.0, 5.0, 1.0, 1.0])) ms.merge_range = 0.05 # Print out information in a convoluted way to test some convoluted features!.. ms2 = MeanShift() ms2.copy_kernel(ms) print 'Kernel:', ms2.get_kernel() del ms2 # For our first trick visualise the data set... img = numpy.zeros((size, size, 3), dtype=numpy.float32) for sample in data: s_x = (size - 1) * sample[1] / scale s_y = (size - 1) * sample[0] / scale e_x = (size - 1) * (sample[1] + angle_len * sample[3]) / scale e_y = (size - 1) * (sample[0] + angle_len * sample[2]) / scale for i in xrange(angle_step): t = float(i) / (angle_step - 1) t_x = int(t * s_x + (1 - t) * e_x)