void median_filter_image(const image_matrix & input_image_, image_matrix & filtered_image_, const int window_size_, const int start_[2], const int end_[2]) { for (int r = start_[Y]; r < end_[Y]; r++) { for (int c = start_[X]; c <end_[X]; c++) { filtered_image_.set_pixel(r, c, median_filter_pixel(input_image_, r, c, window_size_)); } } }
// function run by each thread void* func( void* arg ){ task* t_arg = ( task* )arg; int start = t_arg->start_row; int stop = t_arg->stop_row; int window_size = t_arg->window_size; image_matrix& input = t_arg->input_image; image_matrix * output_address= t_arg->output_image; //'y' is the same as row //'x' is the same as col for(int y = start; y<=stop; y++){ for(int x=0;x<input.get_n_cols();x++){ float filtered_value = median_filter_pixel(input, y, x, window_size); output_address->set_pixel(y,x,filtered_value); } } pthread_exit( NULL ); }