def target_generator(height, width, x_target, y_target, gamma, amplitude, print_attribute='no_print'): radius = gamma * 3 matrix = np.zeros((height, width)) psf_frame = detection_psf_frame(x_target, y_target, radius) for i in range(psf_frame['y_target_minus_r'], psf_frame['y_target_plus_r']): for j in range(psf_frame['x_target_minus_r'], psf_frame['x_target_plus_r']): x = np.array([((j - x_target) / (gamma * math.sqrt(2))), (((j + 1) - x_target) / (gamma * math.sqrt(2)))]) y = np.array([((i - y_target) / (gamma * math.sqrt(2))), (((i + 1) - y_target) / (gamma * math.sqrt(2)))]) erf_x = erf(x) erf_y = erf(y) integral = amplitude * ((erf_x[1] - erf_x[0]) * (erf_y[1] - erf_y[0])) / (8 * (gamma**2)) matrix[i, j] = integral if (print_attribute == 'print'): print_matrix(matrix, 'target') return matrix
def frame_generator(height, width, x_target, y_target, gamma, amplitude, print_attribute='no_print'): noise = noise_generator(height, width) target = target_generator(height, width, x_target, y_target, gamma, amplitude) matrix = noise + target # matrix = target if (print_attribute == 'print'): print_matrix(matrix, 'frame') return matrix
def noise_generator(height, width, print_attribute='no_print'): matrix = np.zeros((height, width)) row, col = matrix.shape mean = 0 sigma = 1 gauss = np.random.normal(mean, sigma, (row, col)) gauss = gauss.reshape(row, col) noise = matrix + gauss # noise = matrix_module(height, width, noise) if (print_attribute == 'print'): print_matrix(noise, 'noise') return noise # noise_generator('print')
noise = noise_generator(height, width) result_matrix += noise return result_matrix #main amplitude_range = [0.5, 0.6, 0.7, 0.8, 0.9, 1.0] result_amplitude = [] for amplitude_iterator in range(0, len(amplitude_range)): experiment_pre_result = [] for experiment_iterator in range(0, experiment_iterations): targets = target_creator() matrix = frame_generator(targets, amplitude_range[amplitude_iterator]) print_matrix(matrix, 'checkRobastFrame', width, height) pre_result_targets = true_robust_algorithm(matrix, gamma, h) robust_targets = search_true_target(pre_result_targets, gamma) result = 0 for i in range(0, len(targets)): for j in range(0, len(robust_targets)): if (targets[i]['x'] == robust_targets[j]['x']) and ( targets[i]['y'] == robust_targets[j]['y']): result += 1 break experiment_pre_result.append(result) result_amplitude.append(experiment_pre_result) x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] # for amplitude_iterator in range(0, len(amplitude_range)): # y = np.zeros(11)