--- /dev/null
+// -------------------------------------------------------------------------
+// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+// -------------------------------------------------------------------------
+
+#ifndef __CPEXTENSIONS__ALGORITHMS__REGIONOFINTERESTIMAGECALCULATOR__HXX__
+#define __CPEXTENSIONS__ALGORITHMS__REGIONOFINTERESTIMAGECALCULATOR__HXX__
+
+#include <itkImageRegionConstIteratorWithIndex.h>
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+void cpExtensions::Algorithms::RegionOfInterestImageCalculator< _TImage >::
+Compute( )
+{
+ typedef itk::ImageRegionConstIteratorWithIndex< _TImage > _TIterator;
+ typedef typename _TImage::RegionType _TRegion;
+
+ if( this->m_Image.IsNotNull( ) )
+ {
+ _TRegion region = this->m_Image->GetRequestedRegion( );
+ TIndex minidx = region.GetIndex( );
+ TIndex maxidx = minidx + region.GetSize( );
+ for( unsigned int d = 0; d < _TImage::ImageDimension; ++d )
+ maxidx[ d ] -= 1;
+
+ bool first = true;
+ _TIterator i( this->m_Image, region );
+ for( i.GoToBegin( ); !i.IsAtEnd( ); ++i )
+ {
+ if( i.Get( ) != this->m_BackgroundValue )
+ {
+ TIndex idx = i.GetIndex( );
+ if( !first )
+ {
+ for( unsigned int d = 0; d < _TImage::ImageDimension; ++d )
+ {
+ minidx[ d ] = ( idx[ d ] < minidx[ d ] )? idx[ d ]: minidx[ d ];
+ maxidx[ d ] = ( idx[ d ] > maxidx[ d ] )? idx[ d ]: maxidx[ d ];
+
+ } // rof
+ }
+ else
+ {
+ minidx = maxidx = idx;
+ first = false;
+
+ } // fi
+
+ } // fi
+
+ } // rof
+ this->m_Minimum = minidx;
+ this->m_Maximum = maxidx;
+ }
+ else
+ {
+ this->m_Minimum.Fill( 0 );
+ this->m_Maximum.Fill( 0 );
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+cpExtensions::Algorithms::RegionOfInterestImageCalculator< _TImage >::
+RegionOfInterestImageCalculator( )
+ : Superclass( ),
+ m_BackgroundValue( TPixel( 0 ) )
+{
+ this->m_Minimum.Fill( 0 );
+ this->m_Maximum.Fill( 0 );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+cpExtensions::Algorithms::RegionOfInterestImageCalculator< _TImage >::
+~RegionOfInterestImageCalculator( )
+{
+}
+
+
+/* TODO
+ typename _TImage::ConstPointer m_Image;
+ TPixel m_BackgroundValue;
+ TIndex m_Minimum;
+ TIndex m_Maximum;
+ };
+*/
+
+#endif // __CPEXTENSIONS__ALGORITHMS__REGIONOFINTERESTIMAGECALCULATOR__HXX__
+
+// eof - $RCSfile$