瀏覽代碼

added function to form a ColorImage from arbitrary MultiChannel channels

Johannes Ruehle 11 年之前
父節點
當前提交
3c3fccc8cc
共有 2 個文件被更改,包括 28 次插入1 次删除
  1. 4 1
      core/image/MultiChannelImage3DT.h
  2. 24 0
      core/image/MultiChannelImage3DT.tcc

+ 4 - 1
core/image/MultiChannelImage3DT.h

@@ -141,9 +141,12 @@ public:
 	/** return image for visualization */
   ImageT<P> getChannelT( int z, uint channel = 0 ) const;
 
-  /** return rgb image for visualization */
+  /** return rgb image (reading channels 0, 1, 2) for visualization */
   ColorImage getColor(int z) const;
 
+  /** return rgb image (reading arbitrary three channels) for visualization */
+  ColorImage getColorImageFromChannels(int z, int channel0, int channel1, int channel2) const;
+
   /** calculate image statistics */
   void statistics( P & min, P & max, uint channel = 0 ) const;
 

+ 24 - 0
core/image/MultiChannelImage3DT.tcc

@@ -538,6 +538,30 @@ ColorImage MultiChannelImage3DT<P>::getColor(int z) const
   return img;
 }
 
+template<class P>
+ColorImage MultiChannelImage3DT<P>::getColorImageFromChannels(int z, int channel0, int channel1, int channel2) const
+{
+  assert( z < zsize );
+  assert( numChannels >= std::max( std::max(channel0,channel1),channel2 ) );
+
+  NICE::ColorImage img( xsize, ysize );
+
+  long k = 0;
+
+  for ( int y = 0 ; y < ysize; y++ )
+  {
+    for ( int x = 0 ; x < xsize ; x++, k++ )
+    {
+      img.setPixel( x, y, 0, ( int )( data[channel0][z*xsize*ysize + k] ) );
+      img.setPixel( x, y, 1, ( int )( data[channel1][z*xsize*ysize + k] ) );
+      img.setPixel( x, y, 2, ( int )( data[channel2][z*xsize*ysize + k] ) );
+    }
+  }
+  //showImage(img);
+  //getchar();
+  return img;
+}
+
 template<class P>
 void MultiChannelImage3DT<P>::calcIntegral( uint channel )
 {