UsTK : Ultrasound ToolKit  version 2.0.1 under development (2023-12-07)
usNeedleTrackerSIR2D.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  * Pierre Chatelain
30  * Alexandre Krupa
31  *
32  *****************************************************************************/
33 
34 #ifndef __usNeedleTrackerSIR2D_h_
35 #define __usNeedleTrackerSIR2D_h_
36 
37 // ViSP
38 #include <visp3/core/vpImage.h>
39 #include <visp3/core/vpNoise.h>
40 
41 // UsNeedleDetection
42 #include <visp3/ustk_core/usPolynomialCurve2D.h>
43 
53 class VISP_EXPORT usNeedleTrackerSIR2D
54 {
55 public:
60 
65 
72  double computeLikelihood(const usPolynomialCurve2D &model, const vpImage<unsigned char> &I);
73 
77  usPolynomialCurve2D *getNeedle();
78 
82  usPolynomialCurve2D *getParticle(unsigned int i);
83 
87  double getWeight(unsigned int i);
88 
100  void init(unsigned int dims[2], unsigned int nPoints, unsigned int nParticles, const usPolynomialCurve2D &needle);
101 
112  void init(const vpImage<unsigned char> &I, unsigned int nPoints, unsigned int nParticles,
113  const usPolynomialCurve2D &needle);
114 
118  void resample();
119 
126  void run(vpImage<unsigned char> &I, double v);
127 
131  void setSigma(double s);
132 
136  void setSigma1(double s);
137 
141  void setSigma2(double s);
142 
143 private:
144  unsigned int m_nParticles;
145  unsigned int m_nPoints;
146  unsigned int m_nPointsCurrent;
147  usPolynomialCurve2D *m_needleModel;
148  usPolynomialCurve2D **m_particles;
149  double *m_weights;
150  vpGaussRand m_noise;
151  vpUniRand m_sample;
152  vpMatrix m_sigma;
153  double m_lengthThreshold;
154 
155  // Image parameters
156  unsigned int m_dims[2];
157  double m_fgMean;
158  double m_bgMean;
159 };
160 
161 #endif // __usNeedleTrackerSIR2D_h_
Needle detection in 2D images based on particle filtering.