Skip to content

Commit

Permalink
Fix unittest on Mac OSX due to different libpng versions
Browse files Browse the repository at this point in the history
  • Loading branch information
liuliu committed Dec 24, 2014
1 parent ed23140 commit 674d70c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/ccv_algebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ double ccv_normalize(ccv_matrix_t* a, ccv_matrix_t** b, int btype, int flag)
for (i = 0; i < da->rows; i++) \
{ \
for (j = 0; j < da->cols; j++) \
sum += _for_get(a_ptr, j, 0); \
sum += fabs((double)_for_get(a_ptr, j, 0)); \
a_ptr += da->step; \
} \
inv = 1.0 / sum; \
Expand Down
Binary file modified test/unit/data/street.g100.bin
Binary file not shown.
Binary file modified test/unit/data/street.g101.bin
Binary file not shown.
11 changes: 8 additions & 3 deletions test/unit/numeric.tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,21 @@ double gaussian(double x, double y, void* data)
TEST_CASE("Gaussian blur with kernel size even & odd")
{
ccv_dense_matrix_t* image = 0;
ccv_read("../../samples/street.png", &image, CCV_IO_GRAY | CCV_IO_ANY_FILE);
// Different versions of libpng uses different RGB => Gray transform values, therefore, operation on RGB space
ccv_read("../../samples/street.png", &image, CCV_IO_ANY_FILE);
ccv_dense_matrix_t* kernel = ccv_dense_matrix_new(100, 100, CCV_32F | CCV_GET_CHANNEL(image->type), 0, 0);
ccv_filter_kernel(kernel, gaussian, 0);
ccv_normalize(kernel, (ccv_matrix_t**)&kernel, 0, CCV_L1_NORM);
double sum = ccv_sum(kernel, CCV_UNSIGNED);
// Normalize
ccv_scale(kernel, (ccv_matrix_t**)&kernel, 0, CCV_GET_CHANNEL(image->type) / sum);
ccv_dense_matrix_t* x = 0;
ccv_filter(image, kernel, &x, CCV_32F, 0);
ccv_matrix_free(kernel);
kernel = ccv_dense_matrix_new(101, 101, CCV_32F | CCV_GET_CHANNEL(image->type), 0, 0);
ccv_filter_kernel(kernel, gaussian, 0);
ccv_normalize(kernel, (ccv_matrix_t**)&kernel, 0, CCV_L1_NORM);
sum = ccv_sum(kernel, CCV_UNSIGNED);
// Normalize
ccv_scale(kernel, (ccv_matrix_t**)&kernel, 0, CCV_GET_CHANNEL(image->type) / sum);
ccv_dense_matrix_t* y = 0;
ccv_filter(image, kernel, &y, CCV_32F, 0);
ccv_matrix_free(kernel);
Expand Down

0 comments on commit 674d70c

Please sign in to comment.