@@ -23,10 +23,14 @@ using namespace cNS_CodedTarget;
2323/* */
2424/* ********************************************* */
2525
26+ /* * Store the result of a validated extracted circular target
27+ */
28+
2629class cCircTargExtr
2730{
2831 public :
2932 cCircTargExtr (const cExtractedEllipse &);
33+
3034 cEllipse mEllipse ;
3135 tREAL8 mBlack ;
3236 tREAL8 mWhite ;
@@ -51,6 +55,11 @@ cCircTargExtr::cCircTargExtr(const cExtractedEllipse & anEE) :
5155/* */
5256/* ********************************************* */
5357
58+ /* * Class for computing the circular code: make a polar representation , offers mapping polar/cart
59+ *
60+ *
61+ * */
62+
5463class cCCDecode
5564{
5665 public :
@@ -63,17 +72,19 @@ class cCCDecode
6372 const cOneEncoding * EnCode () const ;
6473 private :
6574
66- tREAL8 Dev (int aK1,int aK2) const ;
67- tREAL8 Avg (int aK1,int aK2) const ;
68- tREAL8 DevOfPhase (int aK0) const ;
69-
70- tREAL8 K2Rho (int aK) const ;
71- tREAL8 K2Teta (int aK) const ;
72- int Rho2K (tREAL8 aR) const ;
73- cPt2dr KTetaRho2Im (const cPt2di & aKTetaRho) const ;
75+ // Aggregation
76+ tREAL8 StdDev (int aK1,int aK2) const ; // /< standard deviation of the interval
77+ tREAL8 Avg (int aK1,int aK2) const ; // /< average of the interval
78+ tREAL8 TotalStdDevOfPhase (int aK0) const ; // /< Sum of standard dev, on all interval, for a given stard
7479
80+ // Geometric correspondances
81+ tREAL8 K2Rho (int aK) const ; // / index of rho 2 real rho
82+ tREAL8 K2Teta (int aK) const ; // / index of teta 2 real teta
83+ int Rho2K (tREAL8 aR) const ; // / real rho 2 index of rho
84+ cPt2dr KTetaRho2Im (const cPt2di & aKTetaRho) const ; // / index rho-teta 2 cartesian coordinates
7585 tREAL8 RhoOfWeight (const tREAL8 &) const ;
7686
87+
7788 cCircTargExtr & mEE ;
7889 const cDataIm2D<tREAL4> & mDIm ;
7990 const cFullSpecifTarget & mSpec ;
@@ -100,8 +111,75 @@ class cCCDecode
100111 const cOneEncoding * mEnCode ;
101112};
102113
114+ // ============== constructor ============================
115+
116+ cCCDecode::cCCDecode (cCircTargExtr & anEE,const cDataIm2D<tREAL4> & aDIm,const cFullSpecifTarget & aSpec) :
117+ mEE (anEE),
118+ mDIm (aDIm),
119+ mSpec (aSpec),
120+ mOK (true ),
121+ mPixPerB (10 ),
122+ mNbRho (20 ),
123+ mNbB (mSpec .NbBits()),
124+ mNbTeta (mPixPerB * mNbB ),
125+ mRho0 ((mSpec .Rho_0_EndCCB()+mSpec .Rho_1_BeginCode()) /2.0 ),
126+ mRho1 (mSpec .Rho_2_EndCode() +0.2 ),
127+ mImPolar (cPt2di(mNbTeta ,mNbRho )),
128+ mDIP (mImPolar .DIm()),
129+ mAvg ( mNbTeta ,nullptr ,eModeInitImage::eMIA_Null ),
130+ mDAvg ( mAvg .DIm()),
131+ mKR0 ( Rho2K(RhoOfWeight(0.25 )) ) ,
132+ mKR1 ( Rho2K(RhoOfWeight(0.75 )) ) ,
133+ mPhase0 (-1 ),
134+ mBlack (mEE .mBlack ),
135+ mWhite (mEE .mWhite ),
136+ mBWAmpl (mWhite -mBlack ),
137+ mBWAvg ((mBlack +mWhite )/2.0 ),
138+ mEnCode (nullptr )
139+ {
140+
141+ // compute a polar image
142+ for (int aKTeta=0 ; aKTeta < mNbTeta ; aKTeta++)
143+ {
144+ for (int aKRho=0 ; aKRho < mNbRho ; aKRho++)
145+ {
146+ cPt2dr aPt = KTetaRho2Im (cPt2di (aKTeta,aKRho));
147+ tREAL8 aVal = mDIm .DefGetVBL (aPt,-1 );
148+ if (aVal<0 )
149+ {
150+ mOK =false ;
151+ return ;
152+ }
153+
154+ mDIP .SetV (cPt2di (aKTeta,aKRho),aVal);
155+ }
156+ }
157+
158+ if (!mOK )
159+ return ;
160+
161+ // compute an image
162+ for (int aKTeta=0 ; aKTeta < mNbTeta ; aKTeta++)
163+ {
164+ std::vector<tREAL8> aVGray;
165+ for (int aKRho=mKR0 ; aKRho <= mKR1 ; aKRho++)
166+ {
167+ aVGray.push_back (mDIP .GetV (cPt2di (aKTeta,aKRho)));
168+ }
169+ mDAvg .SetV (aKTeta,NonConstMediane (aVGray));
170+ }
171+
172+ ComputePhaseTeta () ;
173+ if (!mOK ) return ;
174+
175+ ComputeCode (true );
176+ if (!mOK ) return ;
177+ }
178+
179+ // ============= Agregation on interval : StdDev , Avg, TotalStdDevOfPhase ====
180+
103181
104- tREAL8 cCCDecode::Dev (int aK1,int aK2) const
182+ tREAL8 cCCDecode::StdDev (int aK1,int aK2) const
105183{
106184 cComputeStdDev<tREAL8> aCS;
107185 for (int aK=aK1 ; aK<aK2 ; aK++)
@@ -121,28 +199,31 @@ tREAL8 cCCDecode::Avg(int aK1,int aK2) const
121199 return aSom / (aK2-aK1);
122200}
123201
124- tREAL8 cCCDecode::DevOfPhase (int aK0) const
202+ tREAL8 cCCDecode::TotalStdDevOfPhase (int aK0) const
125203{
126204 tREAL8 aSum=0 ;
127205 for (int aKBit=0 ; aKBit<mNbB ; aKBit++)
128206 {
129207 int aK1 = aK0+aKBit*mPixPerB ;
130- aSum += Dev (aK1+1 ,aK1+mPixPerB -1 );
208+ aSum += StdDev (aK1+1 ,aK1+mPixPerB -1 );
131209 }
132210
133211 return aSum / mNbB ;
134212}
135213
214+
215+ // =================
216+
136217void cCCDecode::ComputePhaseTeta ()
137218{
138219 cWhichMin<int ,tREAL8> aMinDev;
139220
140221 for (int aK0=0 ;aK0< mPixPerB ; aK0++)
141- aMinDev.Add (aK0,DevOfPhase (aK0));
222+ aMinDev.Add (aK0,TotalStdDevOfPhase (aK0));
142223
143224 mPhase0 = aMinDev.IndexExtre ();
144225
145- if ( (aMinDev.ValExtre () > 0.1 * Dev (0 ,mNbTeta ))
226+ if ( (aMinDev.ValExtre () > 0.1 * StdDev (0 ,mNbTeta ))
146227 || (aMinDev.ValExtre () > 0.05 * mBWAmpl )
147228 )
148229 {
@@ -206,69 +287,6 @@ tREAL8 cCCDecode::RhoOfWeight(const tREAL8 & aW) const
206287 return (1 -aW) * mSpec .Rho_1_BeginCode () + aW * mSpec .Rho_2_EndCode ();
207288}
208289
209- cCCDecode::cCCDecode (cCircTargExtr & anEE,const cDataIm2D<tREAL4> & aDIm,const cFullSpecifTarget & aSpec) :
210- mEE (anEE),
211- mDIm (aDIm),
212- mSpec (aSpec),
213- mOK (true ),
214- mPixPerB (10 ),
215- mNbRho (20 ),
216- mNbB (mSpec .NbBits()),
217- mNbTeta (mPixPerB * mNbB ),
218- mRho0 ((mSpec .Rho_0_EndCCB()+mSpec .Rho_1_BeginCode()) /2.0 ),
219- mRho1 (mSpec .Rho_2_EndCode() +0.2 ),
220- mImPolar (cPt2di(mNbTeta ,mNbRho )),
221- mDIP (mImPolar .DIm()),
222- mAvg ( mNbTeta ,nullptr ,eModeInitImage::eMIA_Null ),
223- mDAvg ( mAvg .DIm()),
224- mKR0 ( Rho2K(RhoOfWeight(0.25 )) ) ,
225- mKR1 ( Rho2K(RhoOfWeight(0.75 )) ) ,
226- mPhase0 (-1 ),
227- mBlack (mEE .mBlack ),
228- mWhite (mEE .mWhite ),
229- mBWAmpl (mWhite -mBlack ),
230- mBWAvg ((mBlack +mWhite )/2.0 ),
231- mEnCode (nullptr )
232- {
233-
234- // compute a polar image
235- for (int aKTeta=0 ; aKTeta < mNbTeta ; aKTeta++)
236- {
237- for (int aKRho=0 ; aKRho < mNbRho ; aKRho++)
238- {
239- cPt2dr aPt = KTetaRho2Im (cPt2di (aKTeta,aKRho));
240- tREAL8 aVal = mDIm .DefGetVBL (aPt,-1 );
241- if (aVal<0 )
242- {
243- mOK =false ;
244- return ;
245- }
246-
247- mDIP .SetV (cPt2di (aKTeta,aKRho),aVal);
248- }
249- }
250-
251- if (!mOK )
252- return ;
253-
254- // compute an image
255- for (int aKTeta=0 ; aKTeta < mNbTeta ; aKTeta++)
256- {
257- std::vector<tREAL8> aVGray;
258- for (int aKRho=mKR0 ; aKRho <= mKR1 ; aKRho++)
259- {
260- aVGray.push_back (mDIP .GetV (cPt2di (aKTeta,aKRho)));
261- }
262- mDAvg .SetV (aKTeta,NonConstMediane (aVGray));
263- }
264-
265- ComputePhaseTeta () ;
266- if (!mOK ) return ;
267-
268- ComputeCode (true );
269- if (!mOK ) return ;
270- }
271-
272290
273291
274292void cCCDecode::Show (const std::string & aPrefix)
0 commit comments