UsTK : Ultrasound ToolKit  version 2.0.1 under development (2024-12-17)
usMotionEstimation.h
1 /****************************************************************************
2  *
3  * This file is part of the ustk software.
4  * Copyright (C) 2016 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ustk with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * This software was developed at:
17  * Inria Rennes - Bretagne Atlantique
18  * Campus Universitaire de Beaulieu
19  * 35042 Rennes Cedex
20  * France
21  *
22  * If you have questions regarding the use of this file, please contact
23  * Inria at ustk@inria.fr
24  *
25  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27  *
28  * Authors:
29  * Pedro Patlan Rosales
30  * Marc Pouliquen
31  *
32  *****************************************************************************/
33 
34 #ifndef __usMotionEstimation_h_
35 #define __usMotionEstimation_h_
36 
42 #include <visp3/ustk_core/usConfig.h>
43 
44 #if defined(USTK_HAVE_ARMADILLO) && (ARMA_VERSION_MAJOR > 6) && (ARMA_VERSION_MAJOR > 700)
45 
46 #include <algorithm>
47 #include <cmath>
48 #include <iostream>
49 #include <map>
50 #include <visp3/core/vpMatrix.h>
51 #include <visp3/ustk_core/usImageRF2D.h>
52 
53 // Armadillo
54 #include <armadillo>
55 
56 using namespace arma;
57 
74 class VISP_EXPORT usMotionEstimation
75 {
76 public:
77  usMotionEstimation();
78  virtual ~usMotionEstimation();
79  void init(mat M1, mat M2, int blk_w, int blk_h, int sr_w, int sr_h);
80  void init(const usImageRF2D<short int> &usM1, const usImageRF2D<short int> &usM2, int blk_w, int blk_h, int sr_w,
81  int sr_h);
82  void run();
83  vec FullSearch(mat block, int xc, int yc, int sr_w, int sr_h);
84  vec TaylorApp(mat B1, mat B2);
85  mat xDifferential(mat input);
86  mat yDifferential(mat input);
87  mat MedianFilt2D(mat M, int kw, int kh);
88  mat getU(void) { return m_U; }
89  mat getV(void) { return m_V; }
90  vpMatrix getU_vp(void) { return convert_mat2vpMatrix(m_U); }
91  vpMatrix getV_vp(void) { return convert_mat2vpMatrix(m_V); }
92  void saveU(const char *t_s);
93  void saveV(const char *t_s);
94  mat convert_usImageRF2mat(const usImageRF2D<short> &vI);
95  vpMatrix convert_mat2vpMatrix(mat vI);
96 
97 private:
98  mat m_M1;
99  mat m_M2;
100  mat m_U;
101  mat m_V;
102  int m_Wblock;
103  int m_Hblock;
104  int m_WSregion;
105  int m_HSregion;
106  ivec m_blk_rngX;
107  ivec m_blk_rngY;
108  ivec m_xcRng;
109  ivec m_ycRng;
110  int m_Lx;
111  int m_Ly;
112 };
113 
114 #endif // ARMADILLO
115 #endif // __usMotionEstimation_h_