浏览代码

removed redundant member function & small fixes

Sven Sickert 11 年之前
父节点
当前提交
5c390ea404
共有 2 个文件被更改,包括 14 次插入60 次删除
  1. 0 3
      core/image/MultiChannelImage3DT.h
  2. 14 57
      core/image/MultiChannelImage3DT.tcc

+ 0 - 3
core/image/MultiChannelImage3DT.h

@@ -140,9 +140,6 @@ public:
   /** convert to ice image */
   void convertToGrey( NICE::Image & img, int z, uint channel = 0, bool normalize = true ) const;
 
-	/** convert to ice image template */
-  void convertToGrey( NICE::ImageT<P> & img, int z, uint channel = 0, bool normalize = false ) const;
-	
   /** convert to ice colorimage */
   void convertToColor( NICE::ColorImage & img, int z, const int chan1 = 0, const int chan2 = 1, const int chan3 = 2 ) const;
 

+ 14 - 57
core/image/MultiChannelImage3DT.tcc

@@ -431,76 +431,32 @@ ImageT<P> MultiChannelImage3DT<P>::getChannelT( int z, uint channel ) const
 {
   assert( channel < numChannels );
 
-  NICE::ImageT<P> img;
-  // TODO do not convert to grey since we are using a template class image
-  convertToGrey( img, z, channel, false );
-  
-  P min, max;
-  statistics ( min, max, channel );
-  fprintf (stderr, "MultiChannelImage3DT<>::showChannel: max %f min %f\n", (double)max, (double)min );
+  //  P min, max;
+  //  statistics ( min, max, channel );
+  //  fprintf (stderr, "MultiChannelImage3DT<>::showChannel: max %f min %f\n", (double)max, (double)min );
 
-  return img;
-}
+  NICE::ImageT<P> img(xsize,ysize);
 
-/** convert to ice image */
-template<class P>
-void MultiChannelImage3DT<P>::convertToGrey( NICE::Image & img, int z, uint channel,  bool normalize ) const
-{
-  assert( channel < numChannels );
-
-  P min, max;
-
-  if ( normalize ) {
-    statistics( min, max, channel );
-    fprintf( stderr, "MultiChannelImage3DT<>::showChannel: max %f min %f\n", ( double )max, ( double )min );
-  }
-
-  bool skip_assignment = false;
-
-  img.resize( xsize, ysize );
-
-  if ( normalize )
-    if ( max - min < std::numeric_limits<double>::min() )
+  long k = 0;
+  for ( int y = 0; y < ysize; y++ )
+    for( int x = 0; x < xsize; x++, k++ )
     {
-      img.set( max );
-      skip_assignment = true;
-      fprintf( stderr, "MultiChannelImage3DT::showChannel: image is uniform! (%f)\n", ( double )max );
+      img.setPixel( x, y, data[channel][z*xsize*ysize + k] );
     }
 
-
-  if ( ! skip_assignment )
-  {
-    long k = 0;
-
-    for ( int y = 0 ; y < ysize; y++ )
-    {
-      for ( int x = 0 ; x < xsize ; x++, k++ )
-      {
-        if ( normalize )
-        {
-          img.setPixel( x, y, ( int )(( data[channel][z*xsize*ysize + k] - min ) * 255 / ( max - min ) ) );
-        }
-        else
-        {
-          img.setPixel( x, y, ( int )( data[channel][z*xsize*ysize + k] ) );
-        }
-      }
-    }
-  }
+  return img;
 }
 
-/** convert to ice image template */
+/** convert to ice image */
 template<class P>
-void MultiChannelImage3DT<P>::convertToGrey( NICE::ImageT<P> & img, int z, uint channel,  bool normalize ) const
+void MultiChannelImage3DT<P>::convertToGrey( NICE::Image & img, int z, uint channel,  bool normalize ) const
 {
   assert( channel < numChannels );
 
   P min, max;
 
-  if ( normalize ) {
+  if ( normalize )
     statistics( min, max, channel );
-    fprintf( stderr, "MultiChannelImage3DT<>::showChannel: max %f min %f\n", ( double )max, ( double )min );
-  }
 
   bool skip_assignment = false;
 
@@ -509,9 +465,10 @@ void MultiChannelImage3DT<P>::convertToGrey( NICE::ImageT<P> & img, int z, uint
   if ( normalize )
     if ( max - min < std::numeric_limits<double>::min() )
     {
+      fprintf( stderr, "MultiChannelImage3DT<>::showChannel: max %f min %f\n", ( double )max, ( double )min );
       img.set( max );
       skip_assignment = true;
-      fprintf( stderr, "MultiChannelImage3DT::showChannel: image is uniform! (%f)\n", ( double )max );
+      fprintf( stderr, "MultiChannelImage3DT<>::showChannel: image is uniform! (%f)\n", ( double )max );
     }