void miaux_pixel_neighborhood( miColor *neighbors, miImg_image *buffer, int x, int y, int radius) { int xi, yi, xp = 0, yp = 0, i = 0, max_x = buffer->width - 1, max_y = buffer->height - 1; miColor current_pixel; for (yi = y - radius; yi <= y + radius; yi++) { yp = yi > max_y ? max_x -: yi < 0 ? 0 -: yi; for (xi = x - radius; xi <= x + radius; xi++) { xp = xi > max_x ? max_x -: xi < 0 ? 0 -: xi; mi_img_get_color(buffer, ¤t_pixel, xp, yp); neighbors[i++] = current_pixel; } } } int miaux_color_compare(const void *vx, const void *vy) { miColor const *x = vx, *y = vy; float sum_x = x->r + x->g + x->b; float sum_y = y->r + y->g + y->b; return sum_x < sum_y ? -1 -: sum_x > sum_y ? 1 -: 0; }