|
@@ -55,73 +55,74 @@ void SemSegObliqueTree::preprocessChannels (
|
|
|
CachedExample *ce,
|
|
|
bool isColor ) const
|
|
|
{
|
|
|
- NICE::MultiChannelImageT<int> * img = NULL;
|
|
|
- NICE::MultiChannelImageT<double> * imgD = NULL;
|
|
|
+ NICE::MultiChannelImage3DT<int> * img = NULL;
|
|
|
+ NICE::MultiChannelImage3DT<double> * imgD = NULL;
|
|
|
|
|
|
- imgD = & ce->getDChannel( CachedExample::D_EOH );
|
|
|
+ imgD = & ce->getDChannel3( CachedExample::D_EOH );
|
|
|
assert( imgD->channels() == 0 );
|
|
|
|
|
|
if ( isColor )
|
|
|
{
|
|
|
- img = & ce->getIChannel( CachedExample::I_COLOR );
|
|
|
+ img = & ce->getIChannel3( CachedExample::I_COLOR );
|
|
|
|
|
|
- imgD->reInit ( img->width(), img->height(), 3 );
|
|
|
+ imgD->reInit ( img->width(), img->height(), img->depth(), 3 );
|
|
|
|
|
|
- for ( int y = 0; y < img->height(); y++ )
|
|
|
- for ( int x = 0; x < img->width(); x++ )
|
|
|
- {
|
|
|
- double r = (double)img->get( x, y, 0);
|
|
|
- double g = (double)img->get( x, y, 1);
|
|
|
- double b = (double)img->get( x, y, 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
|
|
|
+ for ( int z = 0; z < img->depth(); z++ )
|
|
|
+ for ( int y = 0; y < img->height(); y++ )
|
|
|
+ for ( int x = 0; x < img->width(); x++ )
|
|
|
{
|
|
|
- imgD->set( x, y, r/255.0, 0 );
|
|
|
- imgD->set( x, y, g/255.0, 1 );
|
|
|
- imgD->set( x, y, b/255.0, 2 );
|
|
|
+ double r = (double)img->get( x, y, z, 0);
|
|
|
+ double g = (double)img->get( x, y, z, 1);
|
|
|
+ double b = (double)img->get( x, y, z, 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, z, cL, 0);
|
|
|
+ imgD->set( x, y, z, ca, 1);
|
|
|
+ imgD->set( x, y, z, cb, 2);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ imgD->set( x, y, z, r/255.0, 0 );
|
|
|
+ imgD->set( x, y, z, g/255.0, 1 );
|
|
|
+ imgD->set( x, y, z, b/255.0, 2 );
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
// remove integer channels
|
|
|
img->freeData();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- img = & ce->getIChannel( CachedExample::I_GRAYVALUES );
|
|
|
+ img = & ce->getIChannel3( CachedExample::I_GRAYVALUES );
|
|
|
|
|
|
// gray values to range [0,1]
|
|
|
- imgD->reInit ( img->width(), img->height(), 1 );
|
|
|
+ imgD->reInit ( img->width(), img->height(), img->depth(), 1 );
|
|
|
|
|
|
- for ( int y = 0; y < img->height(); y++ )
|
|
|
- for ( int x = 0; x < img->width(); x++ )
|
|
|
- {
|
|
|
- double g = (double)img->get( x, y, 0) / 255.0;
|
|
|
- imgD->set( x, y, g, 0);
|
|
|
- }
|
|
|
+ for ( int z = 0; z < img->depth(); z++ )
|
|
|
+ for ( int y = 0; y < img->height(); y++ )
|
|
|
+ for ( int x = 0; x < img->width(); x++ )
|
|
|
+ {
|
|
|
+ double g = (double)img->get( x, y, z, 0) / 255.0;
|
|
|
+ imgD->set( x, y, z, g, 0);
|
|
|
+ }
|
|
|
|
|
|
// remove integer channel
|
|
|
img->freeData();
|
|
|
-
|
|
|
}
|
|
|
|
|
|
img = NULL;
|
|
@@ -134,6 +135,7 @@ void SemSegObliqueTree::initFromConfig( const Config *_conf,
|
|
|
{
|
|
|
conf = _conf;
|
|
|
saveLoadData = conf->gB ( s_confSection, "save_load_data", false );
|
|
|
+ run3Dseg = conf->gB ( s_confSection, "run_3dseg", false );
|
|
|
colorMode = conf->gI ( s_confSection, "color_mode", 0 );
|
|
|
fileLocation = conf->gS ( s_confSection, "datafile", "classifier.data" );
|
|
|
|
|
@@ -162,7 +164,8 @@ void SemSegObliqueTree::train ( const MultiDataset *md )
|
|
|
* ( ( *md ) ["train"] ),
|
|
|
*classNames,
|
|
|
examples,
|
|
|
- imgexamples );
|
|
|
+ imgexamples,
|
|
|
+ run3Dseg );
|
|
|
|
|
|
assert ( examples.size() > 0 );
|
|
|
|