~charon-developers/charon-flow/learningFlowBrock

« back to all changes in this revision

Viewing changes to include/charon/RobustLKDisplay.hxx

  • Committer: Alexander Brock
  • Date: 2014-10-11 16:23:15 UTC
  • Revision ID: brock.alexander@web.de-20141011162315-y5d99ziaz89nsw7z
Last commit before replacing CImg by Armadillo (for linear algebra only)

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include <vector>
32
32
#include <fstream>
33
33
#include <unistd.h>
 
34
#include <armadillo>
34
35
 
35
36
int iteration_limit_reached = 0;
36
37
 
461
462
                cimg_library::cimg::toc();
462
463
        }
463
464
#endif
 
465
        { // time cimg vs. armadillo
 
466
                std::cout << "Matrix fill speed test CImg" << std::endl;
 
467
                std::cout.flush();
 
468
                cimg_library::cimg::tic();
 
469
 
 
470
                int jj = 0;
 
471
                cimg_forXY(img_dx, x, y) {
 
472
                        if (++jj % 23 != 0) {
 
473
                                continue;
 
474
                        }
 
475
                        int ii = 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;
 
485
                                        ii++;
 
486
                                }
 
487
                        }
 
488
                }
 
489
                cimg_library::cimg::toc();
 
490
                
 
491
                std::cout << "Matrix fill speed test Armadillo" << std::endl;
 
492
                std::cout.flush();
 
493
                cimg_library::cimg::tic();
 
494
                
 
495
                jj = 0;
 
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) {
 
500
                                continue;
 
501
                        }
 
502
                        int ii = 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;
 
512
                                        ii++;
 
513
                                }
 
514
                        }
 
515
                }
 
516
                cimg_library::cimg::toc();
 
517
                
 
518
                std::cout << "Matrix fill speed test blank" << std::endl;
 
519
                std::cout.flush();
 
520
                cimg_library::cimg::tic();
 
521
                
 
522
                jj = 0;
 
523
                T tmp_sum = 0;
 
524
                cimg_forXY(img_dx, x, y) {
 
525
                        if (++jj % 23 != 0) {
 
526
                                continue;
 
527
                        }
 
528
                        int ii = 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;
 
538
                                        ii++;
 
539
                                }
 
540
                        }
 
541
                }
 
542
                cimg_library::cimg::toc();
 
543
        }
464
544
 
465
545
 
466
546
        cimg_library::CImg<T>   image(img),