|
@@ -28,6 +28,7 @@ SemSegConvolutionalTree::SemSegConvolutionalTree () : SemanticSegmentation ()
|
|
|
|
|
|
saveLoadData = false;
|
|
|
fileLocation = "classifier.data";
|
|
|
+ colorMode = 0;
|
|
|
|
|
|
fpc = new FPCRandomForests ();
|
|
|
}
|
|
@@ -50,7 +51,7 @@ SemSegConvolutionalTree::~SemSegConvolutionalTree ()
|
|
|
|
|
|
//#################### MEMBER FUNCTIONS #######################//
|
|
|
|
|
|
-void SemSegConvolutionalTree::convertRGBToHSV (
|
|
|
+void SemSegConvolutionalTree::preprocessChannels (
|
|
|
CachedExample *ce,
|
|
|
bool isColor ) const
|
|
|
{
|
|
@@ -69,22 +70,41 @@ void SemSegConvolutionalTree::convertRGBToHSV (
|
|
|
for ( int y = 0; y < img->height(); y++ )
|
|
|
for ( int x = 0; x < img->width(); x++ )
|
|
|
{
|
|
|
- double h,s,v;
|
|
|
double r = (double)img->get( x, y, 0);
|
|
|
double g = (double)img->get( x, y, 1);
|
|
|
double b = (double)img->get( x, y, 2);
|
|
|
|
|
|
- ColorConversion::ccRGBtoHSV(r, g, b, &h, &s, &v);
|
|
|
-
|
|
|
- imgD->set( x, y, h, 0);
|
|
|
- imgD->set( x, y, s, 1);
|
|
|
- imgD->set( x, y, v, 2);
|
|
|
+ if ( colorMode == 1 )
|
|
|
+ {
|
|
|
+ double h,s,v;
|
|
|
+ ColorConversion::ccRGBtoHSV(r, g, b, &h, &s, &v);
|
|
|
+ imgD->set( x, y, h, 0);
|
|
|
+ imgD->set( x, y, s, 1);
|
|
|
+ imgD->set( x, y, v, 2);
|
|
|
+ }
|
|
|
+ else if ( colorMode == 2 )
|
|
|
+ {
|
|
|
+ double cX, cY, cZ, cL, ca, cb;
|
|
|
+ r /= 255.0;
|
|
|
+ g /= 255.0;
|
|
|
+ b /= 255.0;
|
|
|
+ ColorConversion::ccRGBtoXYZ( r, g, b, &cX, &cY, &cZ, 0 );
|
|
|
+ ColorConversion::ccXYZtoCIE_Lab( cX, cY, cZ, &cL, &ca, &cb, 0 );
|
|
|
+ imgD->set( x, y, cL, 0);
|
|
|
+ imgD->set( x, y, ca, 1);
|
|
|
+ imgD->set( x, y, cb, 2);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ imgD->set( x, y, r/255.0, 0 );
|
|
|
+ imgD->set( x, y, g/255.0, 1 );
|
|
|
+ imgD->set( x, y, b/255.0, 2 );
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// remove integer channels
|
|
|
img->freeData();
|
|
|
}
|
|
|
- // FIXME: never true because of CachedExample implementation of getXChannel
|
|
|
else
|
|
|
{
|
|
|
img = & ce->getIChannel( CachedExample::I_GRAYVALUES );
|
|
@@ -114,6 +134,7 @@ void SemSegConvolutionalTree::initFromConfig( const Config *_conf,
|
|
|
{
|
|
|
conf = _conf;
|
|
|
saveLoadData = conf->gB ( s_confSection, "save_load_data", false );
|
|
|
+ colorMode = conf->gI ( s_confSection, "color_mode", 0 );
|
|
|
fileLocation = conf->gS ( s_confSection, "datafile", "classifier.data" );
|
|
|
|
|
|
fpc = new FPCRandomForests ( _conf, "FPCRandomForests" );
|
|
@@ -151,7 +172,7 @@ void SemSegConvolutionalTree::train ( const MultiDataset *md )
|
|
|
|
|
|
for ( vector<CachedExample *>::iterator cei = imgexamples.begin();
|
|
|
cei != imgexamples.end(); cei++ )
|
|
|
- convertRGBToHSV ( *cei, cf.isColorMode() );
|
|
|
+ preprocessChannels ( *cei, cf.isColorMode() );
|
|
|
|
|
|
// start training using random forests
|
|
|
fpc->train( fp, examples);
|
|
@@ -187,7 +208,7 @@ void SemSegConvolutionalTree::semanticseg(
|
|
|
DecisionNode *root = forest[0]->getRoot ();
|
|
|
ConvolutionFeature* cf = dynamic_cast<ConvolutionFeature*> (root->f);
|
|
|
|
|
|
- convertRGBToHSV( ce, cf->isColorMode() ); //FIXME!!!
|
|
|
+ preprocessChannels( ce, cf->isColorMode() ); //FIXME!!!
|
|
|
|
|
|
Example pce ( ce, 0, 0 );
|
|
|
for ( int y = 0 ; y < ysize ; y++ )
|