|
@@ -641,11 +641,8 @@ void SemSegContextTree3D::updateProbabilityMaps (
|
|
|
{
|
|
|
double val = getMeanProb ( x, y, z, c, nodeIndices );
|
|
|
|
|
|
- if (useFeat3)
|
|
|
+ if (useFeat3 || useFeat4)
|
|
|
feats ( x, y, z, firstChannel + c ) = val;
|
|
|
-
|
|
|
- if (useFeat4)
|
|
|
- feats ( x, y, z, firstChannel + classes + c ) = val;
|
|
|
}
|
|
|
|
|
|
feats.calcIntegral ( firstChannel + c );
|
|
@@ -843,41 +840,48 @@ void SemSegContextTree3D::train ( const LabeledSet * trainp )
|
|
|
////////////////////////// channel type configuration /////////////////////////
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
- // Type 0: single pixel & pixel-comparison features on gray value channels
|
|
|
- for ( int i = 0; i < rawChannels; i++ )
|
|
|
- channelType.push_back ( 0 );
|
|
|
+ unsigned char shift = 0;
|
|
|
+ std::vector<int> rawChannelsIdx, numClassesIdx;
|
|
|
+ int idx = 0;
|
|
|
+ for ( int i = 0; i < rawChannels; i++, idx++ )
|
|
|
+ rawChannelsIdx.push_back ( idx );
|
|
|
|
|
|
- // Type 1: region channel with unsupervised segmentation
|
|
|
- int shift = 0;
|
|
|
+ for ( int i = 0; i < classes; i++, idx++ )
|
|
|
+ numClassesIdx.push_back ( idx );
|
|
|
+
|
|
|
+
|
|
|
+ /** Type 0: single pixel & pixel-comparison features on gray value channels */
|
|
|
+ // actual values derived from integral values
|
|
|
+ channelsPerType.push_back ( rawChannelsIdx );
|
|
|
+
|
|
|
+ /** Type 1: region channel with unsupervised segmentation */
|
|
|
if ( useFeat1 )
|
|
|
{
|
|
|
- channelType.push_back ( 1 );
|
|
|
- shift++;
|
|
|
+ channelsPerType.push_back ( vector<int>(1, rawChannels) );
|
|
|
+ shift = 1;
|
|
|
}
|
|
|
+ else
|
|
|
+ channelsPerType.push_back ( vector<int>() );
|
|
|
|
|
|
- // Type 2: rectangular and Haar-like features on gray value integral channels
|
|
|
+ /** Type 2: rectangular and Haar-like features on gray value integral channels */
|
|
|
if ( useFeat2 )
|
|
|
- for ( int i = 0; i < rawChannels; i++ )
|
|
|
- channelType.push_back ( 2 );
|
|
|
+ channelsPerType.push_back ( rawChannelsIdx );
|
|
|
+ else
|
|
|
+ channelsPerType.push_back ( vector<int>() );
|
|
|
|
|
|
- // Type 3: type 2 features on context channels
|
|
|
+ /** Type 3: type 2 features on integral probability channels (context) */
|
|
|
if ( useFeat3 )
|
|
|
- for ( int i = 0; i < classes; i++ )
|
|
|
- channelType.push_back ( 3 );
|
|
|
+ channelsPerType.push_back ( numClassesIdx );
|
|
|
+ else
|
|
|
+ channelsPerType.push_back ( vector<int>() );
|
|
|
|
|
|
- // Type 4: type 0 features on context channels
|
|
|
+ /** Type 4: type 0 features on probability channels (context) */
|
|
|
+ // Type 4 channels are now INTEGRAL
|
|
|
+ // This remains for compatibility reasons.
|
|
|
if ( useFeat4 )
|
|
|
- for ( int i = 0; i < classes; i++ )
|
|
|
- channelType.push_back ( 4 );
|
|
|
-
|
|
|
- // 'amountTypes' sets upper bound for usable feature types
|
|
|
- int amountTypes = 6;
|
|
|
- channelsPerType = vector<vector<int> > ( amountTypes, vector<int>() );
|
|
|
-
|
|
|
- for ( int i = 0; i < ( int ) channelType.size(); i++ )
|
|
|
- {
|
|
|
- channelsPerType[channelType[i]].push_back ( i );
|
|
|
- }
|
|
|
+ channelsPerType.push_back ( numClassesIdx );
|
|
|
+ else
|
|
|
+ channelsPerType.push_back ( vector<int>() );
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -1453,29 +1457,14 @@ void SemSegContextTree3D::addFeatureMaps (
|
|
|
// intergal images of raw channels
|
|
|
if ( useFeat2 )
|
|
|
{
|
|
|
- imgData.addChannel ( rawChannels );
|
|
|
-
|
|
|
#pragma omp parallel for
|
|
|
for ( int i = 0; i < rawChannels; i++ )
|
|
|
- {
|
|
|
- int corg = i;
|
|
|
- int cint = i + rawChannels + shift;
|
|
|
-
|
|
|
- for ( int z = 0; z < zsize; z++ )
|
|
|
- for ( int y = 0; y < ysize; y++ )
|
|
|
- for ( int x = 0; x < xsize; x++ )
|
|
|
- imgData ( x, y, z, cint ) = imgData ( x, y, z, corg );
|
|
|
-
|
|
|
- imgData.calcIntegral ( cint );
|
|
|
- }
|
|
|
+ imgData.calcIntegral ( i );
|
|
|
}
|
|
|
|
|
|
int classes = classNames->numClasses() - forbidden_classes.size();
|
|
|
|
|
|
- if ( useFeat3 )
|
|
|
- imgData.addChannel ( classes );
|
|
|
-
|
|
|
- if ( useFeat4 )
|
|
|
+ if ( useFeat3 || useFeat4 )
|
|
|
imgData.addChannel ( classes );
|
|
|
|
|
|
}
|
|
@@ -1773,28 +1762,10 @@ void SemSegContextTree3D::classify (
|
|
|
|
|
|
if ( useFeat1 )
|
|
|
{
|
|
|
- int rchannel = -1;
|
|
|
- for ( uint i = 0; i < channelType.size(); i++ )
|
|
|
- {
|
|
|
- if ( channelType[i] == 1 )
|
|
|
- {
|
|
|
- rchannel = i;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- assert ( rchannel > -1 );
|
|
|
-
|
|
|
for ( int z = 0; z < zsize; z++ )
|
|
|
- {
|
|
|
for ( int y = 0; y < ysize; y++ )
|
|
|
- {
|
|
|
for ( int x = 0; x < xsize; x++ )
|
|
|
- {
|
|
|
- regions.set ( x, y, imgData ( x, y, z, rchannel ), ( uint ) z );
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ regions.set ( x, y, imgData ( x, y, z, rawChannels ), ( uint ) z );
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -1992,6 +1963,18 @@ void SemSegContextTree3D::store ( std::ostream & os, int format ) const
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ vector<int> channelType;
|
|
|
+ if ( useFeat0 )
|
|
|
+ channelType.push_back(0);
|
|
|
+ if ( useFeat1 )
|
|
|
+ channelType.push_back(1);
|
|
|
+ if ( useFeat2 )
|
|
|
+ channelType.push_back(2);
|
|
|
+ if ( useFeat3 )
|
|
|
+ channelType.push_back(3);
|
|
|
+ if ( useFeat4 )
|
|
|
+ channelType.push_back(4);
|
|
|
+
|
|
|
os << channelType.size() << endl;
|
|
|
for ( int i = 0; i < ( int ) channelType.size(); i++ )
|
|
|
{
|
|
@@ -2086,7 +2069,7 @@ void SemSegContextTree3D::restore ( std::istream & is, int format )
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- channelType.clear();
|
|
|
+ // channel type configuration
|
|
|
int ctsize;
|
|
|
is >> ctsize;
|
|
|
for ( int i = 0; i < ctsize; i++ )
|
|
@@ -2095,30 +2078,14 @@ void SemSegContextTree3D::restore ( std::istream & is, int format )
|
|
|
is >> tmp;
|
|
|
switch (tmp)
|
|
|
{
|
|
|
- case 0: useFeat0 = true; break;
|
|
|
- case 1: useFeat1 = true; break;
|
|
|
- case 2: useFeat2 = true; break;
|
|
|
- case 3: useFeat3 = true; break;
|
|
|
- case 4: useFeat4 = true; break;
|
|
|
+ case 0: useFeat0 = true; break;
|
|
|
+ case 1: useFeat1 = true; break;
|
|
|
+ case 2: useFeat2 = true; break;
|
|
|
+ case 3: useFeat3 = true; break;
|
|
|
+ case 4: useFeat4 = true; break;
|
|
|
}
|
|
|
- channelType.push_back ( tmp );
|
|
|
}
|
|
|
|
|
|
- // integralMap is deprecated but kept in RESTORE
|
|
|
- // for downwards compatibility!
|
|
|
- // std::vector<std::pair<int, int> > integralMap;
|
|
|
- // integralMap.clear();
|
|
|
- // int iMapSize;
|
|
|
- // is >> iMapSize;
|
|
|
- // for ( int i = 0; i < iMapSize; i++ )
|
|
|
- // {
|
|
|
- // int first;
|
|
|
- // int second;
|
|
|
- // is >> first;
|
|
|
- // is >> second;
|
|
|
- // integralMap.push_back ( pair<int, int> ( first, second ) );
|
|
|
- // }
|
|
|
-
|
|
|
is >> rawChannels;
|
|
|
|
|
|
is >> uniquenumber;
|