void forward_network() { all_filters_update (); all_dendrites_update (); all_neurons_update (); all_outputs_update (); }
// Trains the visual search module void visual_search_thin_train(void) { set_neuron_layer_band_gaussian(&nl_v1_activation_map,HIGHEST_OUTPUT,(float)BAND_WIDTH/2.0,BAND_WIDTH); filter_update(get_filter_by_name((char*)"nl_v1_activation_map_f_filter")); train_neuron_layer((char*)"nl_v1_activation_map"); save_gaussian_filtered_training_pattern(&nl_v1_activation_map); all_filters_update(); all_outputs_update(); }
void segment_draw_line (NEURON_LAYER *nl_segment, int x_center, int y_center, double alpha) { NEURON *neuron_vector = nl_segment->neuron_vector; int width = nl_segment->dimentions.x; int height = nl_segment->dimentions.y; double dx = cos (alpha), dy = sin (alpha), i = 0; int x0 = x_center - (int) (dx * 0.5 * (double) height); int y0 = y_center - (int) (dy * 0.5 * (double) height); for (i = 0.0; i < height; i += 1.0) { int x = x0 + (int) (dx * i); int y = y0 + (int) (dy * i); if (x < 0 || x >= width || y < 0 || y >= height) break; neuron_vector[y * width + x].output.ival = 0; } all_outputs_update (); }
void input_generator (INPUT_DESC *input, int status) { if (input->win == 0) { init_visual_search_thin (input); } else { if (status == MOVE) { check_input_bounds (input, input->wxd, input->wxd); glutSetWindow (input->win); input_display (); update_input_filters(); all_dendrites_update (); all_neurons_update (); filter_update(get_filter_by_name((char*)"nl_v1_activation_map_f_filter")); //this filter is obligatory all_outputs_update (); } } }
void segment_set_neural_layer (NEURON_LAYER *nl_segment, NEURON_LAYER *nl_image, int center_x, int center_y) { int width = nl_segment->dimentions.x; int height = nl_segment->dimentions.y; char *reg_int = region_of_interest (nl_image, center_x, center_y, width, height); char *img = segment_image (0.5, 50, 20, reg_int, nl_segment->dimentions.x, nl_segment->dimentions.y); int x, y; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { nl_segment->neuron_vector[y * nl_segment->dimentions.x + x].output.ival = PIXEL(img[3 * (y * nl_segment->dimentions.x + x) + 0], img[3 * (y * nl_segment->dimentions.x + x) + 1], img[3 * (y * nl_segment->dimentions.x + x) + 2]); } } all_outputs_update (); free(img); free(reg_int); }
void input_generator (INPUT_DESC *input, int status) { if ((input->win != 0) && (status == MOVE)) { update_input_neurons (input); check_input_bounds (input, input->wxd, input->wyd); glutSetWindow(input->win); input_display (); all_filters_update (); all_outputs_update (); } if (input->win == 0) { int x, y; make_input_image (input); init (input); glutInitWindowSize (input->ww, input->wh); if (read_window_position (input->name, &x, &y)) glutInitWindowPosition (x, y); else glutInitWindowPosition (-1, -1); input->win = glutCreateWindow (input->name); glGenTextures (1, (GLuint *)(&(input->tex))); input_init (input); glutReshapeFunc (input_reshape); glutDisplayFunc (input_display); glutKeyboardFunc (keyboard); glutPassiveMotionFunc (input_passive_motion); glutMouseFunc (input_mouse); } }
void get_right_trunk_limit (NEURON_LAYER *nl_segment, int initial_x, int initial_y, int *x_limit, int *y_limit) { int xo, yo, i; int trunk_value, value; trunk_value = nl_segment->neuron_vector[initial_y * nl_segment->dimentions.x + initial_x].output.ival; xo = initial_x; yo = initial_y; while(1) { nl_segment->neuron_vector[yo * nl_segment->dimentions.x + xo].output.ival = 0; all_outputs_update (); if ((xo + 1) < nl_segment->dimentions.x) { value = nl_segment->neuron_vector[yo * nl_segment->dimentions.x + (xo+1)].output.ival; if (value == trunk_value) { xo++; continue; } } if ((xo + 1) < nl_segment->dimentions.x && (yo + 1) < nl_segment->dimentions.y) { value = nl_segment->neuron_vector[(yo+1) * nl_segment->dimentions.x + (xo+1)].output.ival; if (value == trunk_value) { xo++; yo++; continue; } } if ((xo + 1) < nl_segment->dimentions.x && (yo - 1) < nl_segment->dimentions.y) { value = nl_segment->neuron_vector[(yo-1) * nl_segment->dimentions.x + (xo+1)].output.ival; if (value == trunk_value) { xo++; yo--; continue; } } if ((xo + 1) < nl_segment->dimentions.x) { for(i = 0; i < nl_segment->dimentions.y; i++) { value = nl_segment->neuron_vector[i * nl_segment->dimentions.x + (xo+1)].output.ival; if (value == trunk_value) { xo++; yo = i; break; } } if (i < nl_segment->dimentions.y) continue; } *x_limit = xo; *y_limit = yo; break; } }