@@ -17,15 +17,50 @@ namespace MMVII
1717
1818using namespace cNS_CodedTarget ;
1919
20+ /* ********************************************* */
21+ /* */
22+ /* cCircTargExtr */
23+ /* */
24+ /* ********************************************* */
25+
26+ class cCircTargExtr
27+ {
28+ public :
29+ cCircTargExtr (const cExtractedEllipse &);
30+ cEllipse mEllipse ;
31+ tREAL8 mBlack ;
32+ tREAL8 mWhite ;
33+ bool mMarked4Test ;
34+ bool mWithCode ;
35+ cOneEncoding mEncode ;
36+ };
37+
38+ cCircTargExtr::cCircTargExtr (const cExtractedEllipse & anEE) :
39+ mEllipse (anEE.mEllipse ),
40+ mBlack (anEE.mSeed .mBlack ),
41+ mWhite (anEE.mSeed .mWhite ),
42+ mMarked4Test (anEE.mSeed .mMarked4Test ),
43+ mWithCode (false )
44+ {
45+ }
46+
47+
48+ /* ********************************************* */
49+ /* */
50+ /* cCCDecode */
51+ /* */
52+ /* ********************************************* */
53+
2054class cCCDecode
2155{
2256 public :
23- cCCDecode (const cExtractedEllipse & anEE,const cDataIm2D<tREAL4> & aDIm,const cFullSpecifTarget &);
57+ cCCDecode (cCircTargExtr & anEE,const cDataIm2D<tREAL4> & aDIm,const cFullSpecifTarget &);
2458
2559 void Show (const std::string & aPrefix);
2660
2761 void ComputePhaseTeta () ;
2862 void ComputeCode (bool Show) ;
63+ const cOneEncoding * EnCode () const ;
2964 private :
3065
3166 tREAL8 Dev (int aK1,int aK2) const ;
@@ -39,7 +74,7 @@ class cCCDecode
3974
4075 tREAL8 RhoOfWeight (const tREAL8 &) const ;
4176
42- const cExtractedEllipse & mEE ;
77+ cCircTargExtr & mEE ;
4378 const cDataIm2D<tREAL4> & mDIm ;
4479 const cFullSpecifTarget & mSpec ;
4580
@@ -65,6 +100,7 @@ class cCCDecode
65100 const cOneEncoding * mEnCode ;
66101};
67102
103+
68104tREAL8 cCCDecode::Dev (int aK1,int aK2) const
69105{
70106 cComputeStdDev<tREAL8> aCS;
@@ -133,9 +169,14 @@ void cCCDecode::ComputeCode(bool Show)
133169
134170 mEnCode = mSpec .EncodingFromCode (aFlag);
135171
172+ if (! mEnCode ) return ;
136173
137- if (Show)
174+ mEE .mWithCode = true ;
175+ mEE .mEncode = cOneEncoding (mEnCode ->Num (),mEnCode ->Code (),mEnCode ->Name ());
176+ if (false )
138177 {
178+ // bool mWithCode;
179+ // cOneEncoding mEncode;
139180 StdOut () << " Adr=" << mEnCode << " " ;
140181 if (mEnCode )
141182 StdOut () << " Name=" << mEnCode ->Name ()
@@ -165,7 +206,7 @@ tREAL8 cCCDecode::RhoOfWeight(const tREAL8 & aW) const
165206 return (1 -aW) * mSpec .Rho_1_BeginCode () + aW * mSpec .Rho_2_EndCode ();
166207}
167208
168- cCCDecode::cCCDecode (const cExtractedEllipse & anEE,const cDataIm2D<tREAL4> & aDIm,const cFullSpecifTarget & aSpec) :
209+ cCCDecode::cCCDecode (cCircTargExtr & anEE,const cDataIm2D<tREAL4> & aDIm,const cFullSpecifTarget & aSpec) :
169210 mEE (anEE),
170211 mDIm (aDIm),
171212 mSpec (aSpec),
@@ -183,8 +224,8 @@ cCCDecode::cCCDecode(const cExtractedEllipse & anEE,const cDataIm2D<tREAL4> & aD
183224 mKR0 ( Rho2K(RhoOfWeight(0.25 )) ) ,
184225 mKR1 ( Rho2K(RhoOfWeight(0.75 )) ) ,
185226 mPhase0 (-1 ),
186- mBlack (mEE .mSeed . mBlack ),
187- mWhite (mEE .mSeed . mWhite ),
227+ mBlack (mEE .mBlack ),
228+ mWhite (mEE .mWhite ),
188229 mBWAmpl (mWhite -mBlack ),
189230 mBWAvg ((mBlack +mWhite )/2.0 ),
190231 mEnCode (nullptr )
@@ -224,7 +265,7 @@ cCCDecode::cCCDecode(const cExtractedEllipse & anEE,const cDataIm2D<tREAL4> & aD
224265 ComputePhaseTeta () ;
225266 if (!mOK ) return ;
226267
227- ComputeCode (false );
268+ ComputeCode (true );
228269 if (!mOK ) return ;
229270}
230271
@@ -246,12 +287,15 @@ void cCCDecode::Show(const std::string & aPrefix)
246287
247288 }
248289 }
249- ComputeCode (true );
250-
251290
252291 aIm.ToFile (aPrefix + " _ImPolar_" +ToStr (aCpt)+" .tif" );
253292}
254293
294+
295+ const cOneEncoding * cCCDecode::EnCode () const {return mEnCode ; }
296+ #if (0)
297+ #endif
298+
255299/* *********************************************************** */
256300/* */
257301/* cAppliExtractCodeTarget */
@@ -277,18 +321,19 @@ class cAppliExtractCircTarget : public cMMVII_Appli,
277321 int ExeOnParsedBox () override ;
278322
279323 void MakeImageLabel ();
324+ void MakeImageFinalEllispe ();
280325
281326 std::string mNameSpec ;
282327 cFullSpecifTarget * mSpec ;
283- bool mVisu ;
328+ bool mVisuLabel ;
329+ bool mVisuElFinal ;
284330 cExtract_BW_Ellipse * mExtrEll ;
285331 cParamBWTarget mPBWT ;
286332
287333 tImGrad mImGrad ;
288- cRGBImage mImVisu ;
289334 cIm2D<tU_INT1> mImMarq ;
290335
291- std::vector<cSeedBWTarget> mVSeeds ;
336+ std::vector<cCircTargExtr> mVCTE ;
292337 cPhotogrammetricProject mPhProj ;
293338
294339 std::string mPrefixOut ;
@@ -305,13 +350,13 @@ cAppliExtractCircTarget::cAppliExtractCircTarget
305350) :
306351 cMMVII_Appli (aVArgs,aSpec),
307352 cAppliParseBoxIm<tREAL4>(*this ,true ,cPt2di(10000 ,10000 ),cPt2di(300 ,300 ),false ) ,
308- mSpec (nullptr ),
309- mVisu (true ),
310- mExtrEll ( nullptr ),
311- mImGrad (cPt2di( 1 , 1 ) ),
312- mImVisu (cPt2di(1 ,1 )),
313- mImMarq (cPt2di(1 ,1 )),
314- mPhProj (*this )
353+ mSpec (nullptr ),
354+ mVisuLabel (false ),
355+ mVisuElFinal ( true ),
356+ mExtrEll ( nullptr ),
357+ mImGrad (cPt2di(1 ,1 )),
358+ mImMarq (cPt2di(1 ,1 )),
359+ mPhProj (*this )
315360
316361{
317362}
@@ -336,45 +381,77 @@ cCollecSpecArg2007 & cAppliExtractCircTarget::ArgOpt(cCollecSpecArg2007 & anArgO
336381 << mPhProj .DPMask ().ArgDirInOpt (" TestMask" ," Mask for selecting point used in detailed mesg/output" )
337382 << AOpt2007 (mPBWT .mMinDiam ," DiamMin" ," Minimum diameters for ellipse" ,{eTA2007::HDV})
338383 << AOpt2007 (mPBWT .mMaxDiam ," DiamMax" ," Maximum diameters for ellipse" ,{eTA2007::HDV})
384+ << AOpt2007 (mVisuLabel ," VisuLabel" ," Make a visualisation of labeled image" ,{eTA2007::HDV})
339385 );
340386}
341387
388+ void cAppliExtractCircTarget::MakeImageFinalEllispe ()
389+ {
390+ cRGBImage aImVisu= cRGBImage::FromFile (mNameIm ,CurBoxIn ());
391+
392+ for (const auto & anEE : mVCTE )
393+ {
394+ const cEllipse & anEl = anEE.mEllipse ;
395+ for (const auto & aMul : {1.0 ,1.2 ,1.4 })
396+ {
397+ aImVisu.DrawEllipse
398+ (
399+ cRGBImage::Blue , // anEE.mWithCode ? cRGBImage::Blue : cRGBImage::Red,
400+ anEl.Center (),
401+ anEl.LGa ()*aMul , anEl.LSa ()*aMul , anEl.TetaGa ()
402+ );
403+ }
404+ if (anEE.mWithCode )
405+ {
406+ aImVisu.DrawString
407+ (
408+ anEE.mEncode .Name (),cRGBImage::Red,
409+ anEl.Center (),cPt2dr (0.5 ,0.5 ),
410+ 3
411+ );
412+
413+ }
414+ }
415+
416+ aImVisu.ToFile (mPrefixOut + " _VisuEllipses.tif" );
417+ }
342418
343419void cAppliExtractCircTarget::MakeImageLabel ()
344420{
421+ cRGBImage aImVisuLabel = cRGBImage::FromFile (mNameIm ,CurBoxIn ());
345422 const cExtract_BW_Target::tDImMarq& aDMarq = mExtrEll ->DImMarq ();
346423 for (const auto & aPix : aDMarq)
347424 {
348425 if (aDMarq.GetV (aPix)==tU_INT1 (eEEBW_Lab::eTmp))
349- mImVisu .SetRGBPix (aPix,cRGBImage::Green);
426+ aImVisuLabel .SetRGBPix (aPix,cRGBImage::Green);
350427
351428 if ( (aDMarq.GetV (aPix)==tU_INT1 (eEEBW_Lab::eBadZ))
352429 || (aDMarq.GetV (aPix)==tU_INT1 (eEEBW_Lab::eElNotOk))
353430 )
354- mImVisu .SetRGBPix (aPix,cRGBImage::Blue);
431+ aImVisuLabel .SetRGBPix (aPix,cRGBImage::Blue);
355432 if (aDMarq.GetV (aPix)==tU_INT1 (eEEBW_Lab::eBadFr))
356- mImVisu .SetRGBPix (aPix,cRGBImage::Cyan);
433+ aImVisuLabel .SetRGBPix (aPix,cRGBImage::Cyan);
357434 if (aDMarq.GetV (aPix)==tU_INT1 (eEEBW_Lab::eBadEl))
358- mImVisu .SetRGBPix (aPix,cRGBImage::Red);
435+ aImVisuLabel .SetRGBPix (aPix,cRGBImage::Red);
359436 if (aDMarq.GetV (aPix)==tU_INT1 (eEEBW_Lab::eAverEl))
360- mImVisu .SetRGBPix (aPix,cRGBImage::Orange);
437+ aImVisuLabel .SetRGBPix (aPix,cRGBImage::Orange);
361438 if (aDMarq.GetV (aPix)==tU_INT1 (eEEBW_Lab::eBadTeta))
362- mImVisu .SetRGBPix (aPix,cRGBImage::Yellow);
439+ aImVisuLabel .SetRGBPix (aPix,cRGBImage::Yellow);
363440 }
364441
365442 for (const auto & aSeed : mExtrEll ->VSeeds ())
366443 {
367444 if (aSeed.mOk )
368445 {
369- mImVisu .SetRGBPix (aSeed.mPixW ,cRGBImage::Red);
370- mImVisu .SetRGBPix (aSeed.mPixTop ,cRGBImage::Yellow);
446+ aImVisuLabel .SetRGBPix (aSeed.mPixW ,cRGBImage::Red);
447+ aImVisuLabel .SetRGBPix (aSeed.mPixTop ,cRGBImage::Yellow);
371448 }
372449 else
373450 {
374- mImVisu .SetRGBPix (aSeed.mPixW ,cRGBImage::Yellow);
451+ aImVisuLabel .SetRGBPix (aSeed.mPixW ,cRGBImage::Yellow);
375452 }
376453 }
377- mImVisu .ToFile (mPrefixOut + " _Label.tif" );
454+ aImVisuLabel .ToFile (mPrefixOut + " _Label.tif" );
378455}
379456
380457
@@ -385,8 +462,6 @@ int cAppliExtractCircTarget::ExeOnParsedBox()
385462 double aT0 = SecFromT0 ();
386463
387464 mExtrEll = new cExtract_BW_Ellipse (APBI_Im (),mPBWT ,mPhProj .MaskWithDef (mNameIm ,CurBoxIn (),false ));
388- if (mVisu )
389- mImVisu = cRGBImage::FromFile (mNameIm ,CurBoxIn ());
390465
391466 double aT1 = SecFromT0 ();
392467 mExtrEll ->ExtractAllSeed ();
@@ -401,18 +476,29 @@ int cAppliExtractCircTarget::ExeOnParsedBox()
401476 for (const auto & anEE : mExtrEll ->ListExtEl () )
402477 {
403478 if (anEE.mSeed .mMarked4Test )
479+ anEE.ShowOnFile (mNameIm ,21 ,mPrefixOut );
480+ if (anEE.mValidated || anEE.mSeed .mMarked4Test )
404481 {
405- // anEE.ShowOnFile(mNameIm,35,mPrefixOut);
482+ cCircTargExtr aCTE (anEE);
483+ mVCTE .push_back (aCTE);
484+ }
485+ }
406486
407- cCCDecode aCCD (anEE,APBI_DIm (),*mSpec );
408- aCCD.Show (mPrefixOut );
409- // ShowCode(anEE,APBI_DIm(),14);
487+ for (auto & anEE : mVCTE )
488+ {
489+ cCCDecode aCCD (anEE,APBI_DIm (),*mSpec );
490+ if (anEE.mMarked4Test )
491+ {
492+ aCCD.Show (mPrefixOut );
410493 }
411494 }
412495
413- if (mVisu )
496+ if (mVisuLabel )
414497 MakeImageLabel ();
415498
499+ if (mVisuElFinal )
500+ MakeImageFinalEllispe ();
501+
416502 delete mExtrEll ;
417503
418504 return EXIT_SUCCESS;
0 commit comments