|
@@ -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 );
|
|
|
}
|
|
|
|
|
|
|