Skip to content

Commit 013e158

Browse files
author
deseilligny
committed
Proto aicon target ok
1 parent 3ff5d95 commit 013e158

File tree

8 files changed

+219
-123
lines changed

8 files changed

+219
-123
lines changed

MMVII/include/MMVII_Image2D.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,15 @@ class cRGBImage
505505
void DrawEllipse(const cPt3di& aCoul,const cPt2dr & aCenter,tREAL8 aGA,tREAL8 aSA,tREAL8 aTeta);
506506
void DrawCircle (const cPt3di& aCoul,const cPt2dr & aCenter,tREAL8 aRay);
507507

508+
static const cPt2dr AlignCentr;
509+
510+
void DrawString
511+
(
512+
const std::string &,const cPt3di& aCoul,
513+
const cPt2dr & aP0,const cPt2dr & aLignm,
514+
tREAL8 aZoom=1, tREAL8 AlphaBackGround =0 , const cPt3di& aCoulBackGround = Gray128,int aSpace=1
515+
);
516+
508517

509518

510519

@@ -521,6 +530,7 @@ class cRGBImage
521530
static const cPt3di Cyan;
522531
static const cPt3di Orange;
523532
static const cPt3di White;
533+
static const cPt3di Gray128;
524534

525535
/// return a lut adapted to visalise label in one chanel (blue), an maximize constrat in 2 other
526536
static std::vector<cPt3di> LutVisuLabRand(int aNbLab);

MMVII/include/MMVII_ImageInfoExtract.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ struct cSeedBWTarget
125125

126126
tREAL4 mBlack;
127127
tREAL4 mWhite;
128+
129+
tREAL4 Contrast() const;
130+
tREAL4 Avg() const;
128131
bool mOk;
129132
bool mMarked4Test;
130133

@@ -175,6 +178,8 @@ class cExtract_BW_Target
175178
bool AnalyseOneConnectedComponents(cSeedBWTarget &);
176179
bool ComputeFrontier(cSeedBWTarget & aSeed);
177180

181+
void TestNewSeed();
182+
178183
protected :
179184

180185
/// Is the point a candidate for seed (+- local maxima)
@@ -183,7 +188,7 @@ class cExtract_BW_Target
183188
/// Update the data for connected component with a new point (centroid, bbox, heap...)
184189
void AddPtInCC(const cPt2di &);
185190
// Prolongat on the vertical, untill its a max or a min
186-
cPt2di Prolongate(cPt2di aPix,bool IsW,tElemIm & aMaxGy) const;
191+
cPt2di Prolongate(cPt2di aPix,bool IsW) const;
187192

188193
/// Extract the accurate frontier point, essentially prepare data to call "cGetPts_ImInterp_FromValue"
189194
cPt2dr RefineFrontierPoint(const cSeedBWTarget & aSeed,const cPt2di & aP0,bool & Ok);

MMVII/src/CodedTarget/CodedTarget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class cOneEncoding : public cMemCheck
7878
{
7979
public :
8080
cOneEncoding();
81-
cOneEncoding(size_t aNum,size_t aCode);
81+
cOneEncoding(size_t aNum,size_t aCode,const std::string & aName="???");
8282
size_t Num() const;
8383
size_t Code() const;
8484
const std::string & Name() const;

MMVII/src/CodedTarget/cCircTargetExtract.cpp

Lines changed: 122 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,50 @@ namespace MMVII
1717

1818
using 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+
2054
class 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+
68104
tREAL8 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

343419
void 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;

MMVII/src/CodedTarget/cGenerateEncoding.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ void AddData(const cAuxAr2007 & anAux,cSpecBitEncoding & aSpec)
7474
/* */
7575
/* ************************************************* */
7676

77-
cOneEncoding::cOneEncoding(size_t aNum,size_t aCode)
77+
cOneEncoding::cOneEncoding(size_t aNum,size_t aCode,const std::string & aName)
7878
{
79-
mName = "???";
79+
mName = aName;
8080

8181
mNC[0] = aNum;
8282
mNC[1] = aCode;

0 commit comments

Comments
 (0)