|
@@ -13,6 +13,7 @@ using namespace NICE;
|
|
|
using namespace OBJREC;
|
|
|
|
|
|
#undef DEBUG_CSURK
|
|
|
+#define UNCERTAINTY
|
|
|
|
|
|
SemSegCsurka::SemSegCsurka ( const Config *conf,
|
|
|
const MultiDataset *md )
|
|
@@ -570,9 +571,6 @@ void SemSegCsurka::doPCA ( Examples &ex )
|
|
|
cout << "converting features using pca finished" << endl;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
void SemSegCsurka::train ( const MultiDataset *md )
|
|
|
{
|
|
|
|
|
@@ -1484,6 +1482,11 @@ void SemSegCsurka::classifyregions ( CachedExample *ce, NICE::Image & segresult,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+#ifdef UNCERTAINTY
|
|
|
+ FloatImage uncert(xsize, ysize);
|
|
|
+#endif
|
|
|
+
|
|
|
if ( classifier != NULL )
|
|
|
{
|
|
|
clog << "[log] SemSegCsruka::classifyregions: Wahrscheinlichkeitskarten erstellen: classifier != NULL" << endl;
|
|
@@ -1502,6 +1505,11 @@ void SemSegCsurka::classifyregions ( CachedExample *ce, NICE::Image & segresult,
|
|
|
fV[j] += r.scores[j];
|
|
|
preMap.set ( pce[i].second.x, pce[i].second.y, r.scores[j], j + s*klassen );
|
|
|
}
|
|
|
+
|
|
|
+#ifdef UNCERTAINTY
|
|
|
+ uncert(pce[i].second.x, pce[i].second.y) = r.uncertainty;
|
|
|
+#endif
|
|
|
+
|
|
|
|
|
|
{
|
|
|
cout << "scores: ";
|
|
@@ -1533,10 +1541,13 @@ void SemSegCsurka::classifyregions ( CachedExample *ce, NICE::Image & segresult,
|
|
|
fV[j] += r.scores[j];
|
|
|
preMap.set ( pce[i].second.x, pce[i].second.y, r.scores[j], j + s*klassen );
|
|
|
}
|
|
|
+#ifdef UNCERTAINTY
|
|
|
+ uncert(pce[i].second.x, pce[i].second.y) = r.uncertainty;
|
|
|
+#endif
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- cout << 1 << endl;
|
|
|
+
|
|
|
vector<double> scalesVec;
|
|
|
for ( set<double>::const_iterator iter = scales.begin();
|
|
|
iter != scales.end();
|
|
@@ -1544,7 +1555,6 @@ void SemSegCsurka::classifyregions ( CachedExample *ce, NICE::Image & segresult,
|
|
|
{
|
|
|
scalesVec.push_back ( *iter );
|
|
|
}
|
|
|
- cout << 2 << endl;
|
|
|
|
|
|
#undef VISSEMSEG
|
|
|
#ifdef VISSEMSEG
|
|
@@ -1629,6 +1639,12 @@ void SemSegCsurka::classifyregions ( CachedExample *ce, NICE::Image & segresult,
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+#ifdef UNCERTAINTY
|
|
|
+ double sigma = sigmaweight * 16.0 * 4.0;
|
|
|
+ FloatImage gaussUncert(xsize,ysize);
|
|
|
+ filterGaussSigmaApproximate<float, float, float> ( uncert, sigma, &gaussUncert );
|
|
|
+#endif
|
|
|
|
|
|
|
|
|
|
|
@@ -1713,10 +1729,12 @@ void SemSegCsurka::classifyregions ( CachedExample *ce, NICE::Image & segresult,
|
|
|
|
|
|
int regionsize = seg->segRegions ( img, mask );
|
|
|
|
|
|
-
|
|
|
-
|
|
|
Regionen.clear();
|
|
|
vector<vector <double> > regionprob;
|
|
|
+
|
|
|
+#ifdef UNCERTAINTY
|
|
|
+ vector<double> regionUncert;
|
|
|
+#endif
|
|
|
|
|
|
|
|
|
for ( int i = 0; i < regionsize; i++ )
|
|
@@ -1728,6 +1746,9 @@ void SemSegCsurka::classifyregions ( CachedExample *ce, NICE::Image & segresult,
|
|
|
}
|
|
|
regionprob.push_back ( tmp );
|
|
|
Regionen.push_back ( pair<int, Example> ( 0, Example() ) );
|
|
|
+#ifdef UNCERTAINTY
|
|
|
+ regionUncert.push_back(0.0);
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1735,15 +1756,18 @@ void SemSegCsurka::classifyregions ( CachedExample *ce, NICE::Image & segresult,
|
|
|
{
|
|
|
for ( int y = 0; y < ysize; y++ )
|
|
|
{
|
|
|
+ int pos = mask ( x, y );
|
|
|
+ Regionen[pos].second.weight += 1.0;
|
|
|
+ Regionen[pos].second.x += x;
|
|
|
+ Regionen[pos].second.y += y;
|
|
|
for ( int j = 0 ; j < ( int ) probabilities.numChannels; j++ )
|
|
|
{
|
|
|
double val = probabilities.get ( x, y, j );
|
|
|
- int pos = mask ( x, y );
|
|
|
- Regionen[pos].second.weight += 1.0;
|
|
|
- Regionen[pos].second.x += x;
|
|
|
- Regionen[pos].second.y += y;
|
|
|
regionprob[pos][j] += val;
|
|
|
}
|
|
|
+#ifdef UNCERTAINTY
|
|
|
+ regionUncert[pos] += gaussUncert(x,y);
|
|
|
+#endif
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1789,6 +1813,9 @@ void SemSegCsurka::classifyregions ( CachedExample *ce, NICE::Image & segresult,
|
|
|
}
|
|
|
|
|
|
Regionen[i].first = maxpos;
|
|
|
+#ifdef UNCERTAINTY
|
|
|
+ regionUncert[i] /= Regionen[i].second.weight;
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1798,8 +1825,22 @@ void SemSegCsurka::classifyregions ( CachedExample *ce, NICE::Image & segresult,
|
|
|
{
|
|
|
int pos = mask ( x, y );
|
|
|
segresult.setPixel ( x, y, Regionen[pos].first );
|
|
|
+#ifdef UNCERTAINTY
|
|
|
+ uncert(x,y) = regionUncert[pos];
|
|
|
+#endif
|
|
|
}
|
|
|
}
|
|
|
+#ifdef UNCERTAINTY
|
|
|
+ std::string s;
|
|
|
+ std::stringstream out;
|
|
|
+ std::vector< std::string > list;
|
|
|
+ StringTools::split ( Globals::getCurrentImgFN (), '/', list );
|
|
|
+ out << "uncertainty/" << list.back();
|
|
|
+ ColorImage imgrgb(xsize,ysize);
|
|
|
+ ICETools::convertToRGB ( uncert, imgrgb );
|
|
|
+ imgrgb.write(out.str());
|
|
|
+#endif
|
|
|
+
|
|
|
#undef WRITEREGIONS
|
|
|
#ifdef WRITEREGIONS
|
|
|
RegionGraph rg;
|
|
@@ -1904,5 +1945,3 @@ void SemSegCsurka::semanticseg ( CachedExample *ce, NICE::Image & segresult, NIC
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
-
|
|
|
-
|