+ // Keep just indices, not points
+ this->m_Polygon.clear( );
+ _TImage* out = this->GetOutput( 0 );
+ TIndex minIdx, maxIdx;
+ for( auto c = this->m_Contour.begin( ); c != this->m_Contour.end( ); ++c )
+ {
+ TIndex idx;
+ out->TransformPhysicalPointToIndex( *c, idx );
+ bool added = true;
+ if( this->m_Polygon.size( ) > 0 )
+ {
+ if( this->m_Polygon.back( ) != idx )
+ {
+ this->m_Polygon.push_back( idx );
+ minIdx[ 0 ] = ( idx[ 0 ] < minIdx[ 0 ] )? idx[ 0 ]: minIdx[ 0 ];
+ minIdx[ 1 ] = ( idx[ 1 ] < minIdx[ 1 ] )? idx[ 1 ]: minIdx[ 1 ];
+ maxIdx[ 0 ] = ( idx[ 0 ] > maxIdx[ 0 ] )? idx[ 0 ]: maxIdx[ 0 ];
+ maxIdx[ 1 ] = ( idx[ 1 ] > maxIdx[ 1 ] )? idx[ 1 ]: maxIdx[ 1 ];
+
+ } // fi
+ }
+ else
+ {
+ this->m_Polygon.push_back( idx );
+ minIdx = maxIdx = idx;
+
+ } // fi
+
+ } // rof
+
+ // Set ROI
+ typename _TImage::SizeType size;
+ size[ 0 ] = maxIdx[ 0 ] - minIdx[ 0 ] + 1;
+ size[ 1 ] = maxIdx[ 1 ] - minIdx[ 1 ] + 1;
+ this->m_ROI.SetIndex( minIdx );
+ this->m_ROI.SetSize( size );