1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- #include <stdio.h>
- #include <vector>
- namespace OBJREC {
- template<class SrcP>
- void SemanticSegmentation::make3DImage ( const std::vector<std::string> & filelist,
- NICE::MultiChannelImage3DT<SrcP> & imgData )
- {
- bool isInit = false;
- for ( int it = 0; it < ( int ) filelist.size(); it++ )
- {
- if ( imagetype == IMAGETYPE_RGB )
- {
- NICE::ColorImage img;
- try
- {
- img.read ( filelist[it] );
- }
- catch ( NICE::ImageException iE )
- {
- fprintf ( stderr, "Failed to open color image file: %s\n", filelist[it].c_str() );
- fprintf ( stderr, "%s\n", iE.what() );
- exit ( -1 );
- }
- if ( !isInit )
- {
- imgData.reInit ( img.width(),img.height(),filelist.size(),3 );
- isInit = true;
- }
- for ( int y = 0; y < img.height(); y++ )
- {
- for ( int x = 0; x < img.width(); x++ )
- {
- for ( int r = 0; r < 3; r++ )
- {
- imgData.set ( x, y, it, (SrcP)img.getPixel ( x,y,r ), r );
- }
- }
- }
- }
- else
- {
- NICE::Image img;
- try
- {
- img.read ( filelist[it] );
- }
- catch ( NICE::ImageException iE )
- {
- fprintf ( stderr, "Failed to open image file: %s\n", filelist[it].c_str() );
- fprintf ( stderr, "%s\n", iE.what() );
- exit ( -1 );
- }
- if ( !isInit )
- {
- imgData.reInit ( img.width(),img.height(),filelist.size(),1 );
- isInit = true;
- }
- for ( int y = 0; y < img.height(); y++ )
- {
- for ( int x = 0; x < img.width(); x++ )
- {
- imgData.set ( x, y, it, (SrcP)img.getPixel ( x,y ), 0 );
- }
- }
- }
- }
- if ( imagetype == IMAGETYPE_GRAY )
- {
- imgData.equalizeHistogram( 0 );
- }
- }
- }
|