461
462
cimg_library::cimg::toc();
465
{ // time cimg vs. armadillo
466
std::cout << "Matrix fill speed test CImg" << std::endl;
468
cimg_library::cimg::tic();
471
cimg_forXY(img_dx, x, y) {
472
if (++jj % 23 != 0) {
476
for (int offset_dx = -rad; offset_dx <= (int)rad; offset_dx++) {
477
for (int offset_dy = -rad; offset_dy <= (int)rad; offset_dy++) {
478
const int weight_index = absmax(offset_dx, offset_dy);
479
const T weight = _weights[weight_index];
480
//std::cout << offset_dx << "\t" << offset_dy << "\t" << weight_index << "\t" << weight << std::endl;
481
A.atXY(0, ii) = weight * img_dx.atXY(x + offset_dx, y + offset_dy);
482
A.atXY(1, ii) = weight * img_dy.atXY(x + offset_dx, y + offset_dy);
483
b.atXY(0, ii) = -weight * img_dt.atXY(x + offset_dx, y + offset_dy);
484
//std::cerr << A[ii][0] << "\t" << A[ii][1] << std::endl;
489
cimg_library::cimg::toc();
491
std::cout << "Matrix fill speed test Armadillo" << std::endl;
493
cimg_library::cimg::tic();
496
arma::Mat<T> arma_A(windowsize, 2, arma::fill::zeros);
497
arma::Col<T> arma_b(windowsize, arma::fill::zeros);
498
cimg_forXY(img_dx, x, y) {
499
if (++jj % 23 != 0) {
503
for (int offset_dx = -rad; offset_dx <= (int)rad; offset_dx++) {
504
for (int offset_dy = -rad; offset_dy <= (int)rad; offset_dy++) {
505
const int weight_index = absmax(offset_dx, offset_dy);
506
const T weight = _weights[weight_index];
507
//std::cout << offset_dx << "\t" << offset_dy << "\t" << weight_index << "\t" << weight << std::endl;
508
arma_A(ii, 0) = weight * img_dx.atXY(x + offset_dx, y + offset_dy);
509
arma_A(ii, 1) = weight * img_dy.atXY(x + offset_dx, y + offset_dy);
510
arma_b(ii) = -weight * img_dt.atXY(x + offset_dx, y + offset_dy);
511
//std::cerr << A[ii][0] << "\t" << A[ii][1] << std::endl;
516
cimg_library::cimg::toc();
518
std::cout << "Matrix fill speed test blank" << std::endl;
520
cimg_library::cimg::tic();
524
cimg_forXY(img_dx, x, y) {
525
if (++jj % 23 != 0) {
529
for (int offset_dx = -rad; offset_dx <= (int)rad; offset_dx++) {
530
for (int offset_dy = -rad; offset_dy <= (int)rad; offset_dy++) {
531
const int weight_index = absmax(offset_dx, offset_dy);
532
const T weight = _weights[weight_index];
533
//std::cout << offset_dx << "\t" << offset_dy << "\t" << weight_index << "\t" << weight << std::endl;
534
tmp_sum += weight * img_dx.atXY(x + offset_dx, y + offset_dy);
535
tmp_sum += weight * img_dy.atXY(x + offset_dx, y + offset_dy);
536
tmp_sum -= weight * img_dt.atXY(x + offset_dx, y + offset_dy);
537
//std::cerr << A[ii][0] << "\t" << A[ii][1] << std::endl;
542
cimg_library::cimg::toc();
466
546
cimg_library::CImg<T> image(img),