object *my_alg_level1(unsigned char *image, unsigned char *mask, int width, int height, int *n_object) { /*********************************MYCODE*********************************/ unsigned int width_sub = 0, height_sub = 0; create_sub_images(image, width, height, &width_sub, &height_sub); /* export_ppm_subimages(3, width, height, width_sub, height_sub); */ calculate_histogram(3, width, height, width_sub, height_sub); calculate_threshold(width, height, width_sub, height_sub); calculate_threshold_with_interpolation(0, width, height, width_sub, height_sub); final_stage(width, height, width_sub, height_sub); /*free_mem_subimages(width, height, width_sub, height_sub);*/ /*********************************MYCODE*********************************/ return NULL/*baseline(image, mask, width, height, n_object)*/; }
/*object *my_alg_level3(unsigned char *image, int width, int height, int *n_object)*/ object *my_alg_level3(unsigned char *image, unsigned char *mask, int width, int height, int *n_object) { /*********************************MYCODE*********************************/ unsigned int width_sub = 0, height_sub = 0; create_sub_images(image, width, height, &width_sub, &height_sub); /*export_ppm_subimages(3, width, height, width_sub, height_sub);*/ calculate_histogram(3, width, height, width_sub, height_sub); calculate_threshold(width, height, width_sub, height_sub); calculate_threshold_with_interpolation(0, width, height, width_sub, height_sub); final_stage(width, height, width_sub, height_sub); /*free_mem_subimages(width, height, width_sub, height_sub);*/ /*********************************MYCODE*********************************/ /* transform_1D_to_2D_RGB(image, width, height); allocate_mem_data_CIELAB(width, height); convert_RGB_to_CIELAB(width, height); unsigned int max_grad = 0; first_derivative_CIELAB(0, width, height, &max_grad); calculate_histogram_of_gradient(width, height, max_grad); histogram_analysis(width, height, max_grad); return NULL; */ return NULL;/*baseline(image, mask, width, height, n_object);*/ }
/*object *my_alg_level2(unsigned char *image, int width, int height, int *n_object)*/ object *my_alg_level2(unsigned char *image, unsigned char *mask, int width, int height, int *n_object) { /*********************************MYCODE*********************************/ unsigned int width_sub = 0, height_sub = 0; create_sub_images(image, width, height, &width_sub, &height_sub); /*export_ppm_subimages(3, width, height, width_sub, height_sub);*/ calculate_histogram(3, width, height, width_sub, height_sub); calculate_threshold(width, height, width_sub, height_sub); calculate_threshold_with_interpolation(0, width, height, width_sub, height_sub); final_stage(width, height, width_sub, height_sub); /*free_mem_subimages(width, height, width_sub, height_sub);*/ /*********************************MYCODE*********************************/ /* transform_1D_to_2D(image, width, height); export_ppm_from_2D(3, width, height); convert_to_greyscale(width, height); noise_reduction(width, height); export_ppm_from_2D(4, width, height); Sobel_operator(3, width,height); non_maximum_suppression(width, height); int high = 0, low = 0; calculate_thresholds(width, height, &high, &low); printf("l:%d h:%d\n", low, high); hysteresis_thresholding(width, height, high, low); export_ppm_from_2D(4, width, height); return NULL; */ return NULL;/*baseline(image, mask, width, height, n_object);*/ }
int handleinput(struct bat *bat, void *buffer, int frames) { switch (bat->latency.state) { /* Measuring average loudness for 1 second */ case LATENCY_STATE_MEASURE_FOR_1_SECOND: bat->latency.sum += sumaudio(bat, buffer, frames); bat->latency.samples += frames; /* 1 second elapsed */ if (bat->latency.samples >= bat->rate) { calculate_threshold(bat); bat->latency.state = LATENCY_STATE_PLAY_AND_LISTEN; bat->latency.samples = 0; bat->latency.sum = 0; } break; /* Playing sine wave and listening if it comes back */ case LATENCY_STATE_PLAY_AND_LISTEN: play_and_listen(bat, buffer, frames); break; /* Waiting 1 second */ case LATENCY_STATE_WAITING: bat->latency.samples += frames; if (bat->latency.samples > bat->rate) { /* 1 second elapsed, start over */ bat->latency.samples = 0; bat->latency.state = LATENCY_STATE_MEASURE_FOR_1_SECOND; } break; default: return 0; } return 0; }
static void compute_ramp (GeglBuffer *dest1, GeglBuffer *dest2, const GeglRectangle *roi, gdouble pct_black, gdouble pct_white, gboolean under_threshold, gdouble *threshold_black, gdouble *threshold_white) { GeglBufferIterator *iter; gint hist1[2000]; gint hist2[2000]; gdouble diff; gint count; iter = gegl_buffer_iterator_new (dest1, roi, 0, babl_format ("Y float"), GEGL_ACCESS_READ, GEGL_ABYSS_NONE); gegl_buffer_iterator_add (iter, dest2, roi, 0, babl_format ("Y float"), GEGL_ACCESS_READ, GEGL_ABYSS_NONE); memset (hist1, 0, sizeof (int) * 2000); memset (hist2, 0, sizeof (int) * 2000); count = 0; while (gegl_buffer_iterator_next (iter)) { gint n_pixels = iter->length; gfloat *ptr1 = iter->data[0]; gfloat *ptr2 = iter->data[1]; while (n_pixels--) { diff = *ptr1 / *ptr2; ptr1++; ptr2++; if (under_threshold) { if (diff < THRESHOLD && diff >= 0.0f) { hist2[(int) (diff * 1000)] ++; count ++; } } else { if (diff >= THRESHOLD && diff < 2.0) { hist1[(int) (diff * 1000)] ++; count ++; } } } } *threshold_black = calculate_threshold (hist1, pct_black, count, 0); *threshold_white = calculate_threshold (hist2, pct_white, count, 1); }