Fix RGB median

This commit is contained in:
iabdalkader 2014-04-04 19:11:26 +02:00
parent 424a278fac
commit 2a33cde156

View File

@ -74,9 +74,11 @@ void add_pixels(image_t * im, int row, int col, int size, histo_t *h)
void init_histo(image_t *im, int row, int size, histo_t *h) void init_histo(image_t *im, int row, int size, histo_t *h)
{ {
//memset(h, 0, sizeof(histo_t)); if (im->bpp==1) {
h->n = 0; h->n = h->h[0] = h->h[1] = 0;
h->h[0] = h->h[1]=0; } else {
memset(h, 0, sizeof(histo_t));
}
for (int j = 0; j < size && j < im->w; j++) { for (int j = 0; j < size && j < im->w; j++) {
add_pixels(im, row, j, size, h); add_pixels(im, row, j, size, h);
} }
@ -93,7 +95,8 @@ uint16_t median(const int *x, int n)
void median_filter_rgb(image_t *in, int size) void median_filter_rgb(image_t *in, int size)
{ {
uint16_t r,g,b; uint16_t r,g,b;
int k_rows = size+1; //int k_rows = size+1;
int k_rows = (2*size+1)*2;
histo_t *h = xalloc(sizeof(*h)); histo_t *h = xalloc(sizeof(*h));
uint16_t *data = xalloc(in->w * k_rows * sizeof(*data)); uint16_t *data = xalloc(in->w * k_rows * sizeof(*data));