From: Leonardo Flórez-Valencia Date: Wed, 27 Sep 2017 21:40:53 +0000 (-0500) Subject: ... X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=23d3dd380d0160579d3fef289fb7e63bb6f4cb51;p=cpPlugins.git ... --- diff --git a/lib/ivq/ITK/RegionOfInterestWithPaddingImageFilter.h b/lib/ivq/ITK/RegionOfInterestWithPaddingImageFilter.h new file mode 100644 index 0000000..4828d8f --- /dev/null +++ b/lib/ivq/ITK/RegionOfInterestWithPaddingImageFilter.h @@ -0,0 +1,62 @@ +/* ======================================================================= + * @author: Leonardo Florez-Valencia + * @email: florez-l@javeriana.edu.co + * ======================================================================= + */ +#ifndef __ivq__ITK__RegionOfInterestWithPaddingImageFilter__h__ +#define __ivq__ITK__RegionOfInterestWithPaddingImageFilter__h__ + +#include + +namespace ivq +{ + namespace ITK + { + /** + */ + template< class _TInput, class _TOutput > + class RegionOfInterestWithPaddingImageFilter + : public itk::RegionOfInterestImageFilter< _TInput, _TOutput > + { + public: + // Basic types + typedef itk::RegionOfInterestImageFilter< _TInput, _TOutput > Superclass; + typedef RegionOfInterestWithPaddingImageFilter Self; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( + ivq::ITK::RegionOfInterestWithPaddingImageFilter, + itk::RegionOfInterestImageFilter + ); + + itkGetConstMacro( Padding, unsigned int ); + itkSetMacro( Padding, unsigned int ); + + protected: + RegionOfInterestWithPaddingImageFilter( ); + virtual ~RegionOfInterestWithPaddingImageFilter( ); + + virtual void GenerateOutputInformation( ) override; + + private: + // Purposely not implemented + RegionOfInterestWithPaddingImageFilter( const Self& ); + void operator=( const Self& ); + + protected: + unsigned int m_Padding; + }; + + } // ecapseman + +} // ecapseman + +#ifndef ITK_MANUAL_INSTANTIATION +# include +#endif // ITK_MANUAL_INSTANTIATION +#endif // __ivq__ITK__RegionOfInterestWithPaddingImageFilter__h__ + +// eof - $RCSfile$ diff --git a/lib/ivq/ITK/RegionOfInterestWithPaddingImageFilter.hxx b/lib/ivq/ITK/RegionOfInterestWithPaddingImageFilter.hxx new file mode 100644 index 0000000..14d1f0e --- /dev/null +++ b/lib/ivq/ITK/RegionOfInterestWithPaddingImageFilter.hxx @@ -0,0 +1,61 @@ +/* ======================================================================= + * @author: Leonardo Florez-Valencia + * @email: florez-l@javeriana.edu.co + * ======================================================================= + */ +#ifndef __ivq__ITK__RegionOfInterestWithPaddingImageFilter__hxx__ +#define __ivq__ITK__RegionOfInterestWithPaddingImageFilter__hxx__ + +// ------------------------------------------------------------------------- +template< class _TInput, class _TOutput > +ivq::ITK::RegionOfInterestWithPaddingImageFilter< _TInput, _TOutput >:: +RegionOfInterestWithPaddingImageFilter( ) + : Superclass( ), + m_Padding( 0 ) +{ +} + +// ------------------------------------------------------------------------- +template< class _TInput, class _TOutput > +ivq::ITK::RegionOfInterestWithPaddingImageFilter< _TInput, _TOutput >:: +~RegionOfInterestWithPaddingImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +template< class _TInput, class _TOutput > +void ivq::ITK::RegionOfInterestWithPaddingImageFilter< _TInput, _TOutput >:: +GenerateOutputInformation( ) +{ + if( this->m_Padding > 0 ) + { + // Apply padding + typename _TInput::RegionType region = + this->GetInput( )->GetLargestPossibleRegion( ); + typename _TInput::RegionType roi = this->GetRegionOfInterest( ); + typename _TInput::IndexType iMin = region.GetIndex( ); + typename _TInput::IndexType iMax = iMin + region.GetSize( ); + typename _TInput::IndexType i0 = roi.GetIndex( ); + typename _TInput::IndexType i1 = i0 + roi.GetSize( ); + typename _TInput::SizeType size; + for( unsigned int d = 0; d < _TInput::ImageDimension; ++d ) + { + i0[ d ] -= this->m_Padding; + i1[ d ] += this->m_Padding; + i0[ d ] = ( i0[ d ] < iMin[ d ] )? iMin[ d ]: i0[ d ]; + i1[ d ] = ( iMax[ d ] < i1[ d ] )? iMax[ d ]: i1[ d ]; + size[ d ] = i1[ d ] - i0[ d ]; + + } // rof + + roi.SetIndex( i0 ); + roi.SetSize( size ); + this->SetRegionOfInterest( roi ); + + } // fi + this->Superclass::GenerateOutputInformation( ); +} + +#endif // __ivq__ITK__RegionOfInterestWithPaddingImageFilter__hxx__ + +// eof - $RCSfile$ diff --git a/lib/ivq/Qt/DicomSeriesSelectorDialog.cxx b/lib/ivq/Qt/DicomSeriesSelectorDialog.cxx index 6e39f34..c3248ed 100644 --- a/lib/ivq/Qt/DicomSeriesSelectorDialog.cxx +++ b/lib/ivq/Qt/DicomSeriesSelectorDialog.cxx @@ -24,6 +24,13 @@ ivq::Qt::DicomSeriesSelectorDialog:: delete this->m_UI; } +// ------------------------------------------------------------------------- +void ivq::Qt::DicomSeriesSelectorDialog:: +setStartDir( const std::string& dir ) +{ + this->m_UI->Selector->setStartDir( dir.c_str( ), true ); +} + // ------------------------------------------------------------------------- std::vector< std::string >* ivq::Qt::DicomSeriesSelectorDialog:: selectedFilenames( ) diff --git a/lib/ivq/Qt/DicomSeriesSelectorDialog.h b/lib/ivq/Qt/DicomSeriesSelectorDialog.h index 973dbcc..ac64b16 100644 --- a/lib/ivq/Qt/DicomSeriesSelectorDialog.h +++ b/lib/ivq/Qt/DicomSeriesSelectorDialog.h @@ -31,6 +31,8 @@ namespace ivq explicit DicomSeriesSelectorDialog( QWidget* parent = 0 ); virtual ~DicomSeriesSelectorDialog( ); + void setStartDir( const std::string& dir ); + std::vector< std::string >* selectedFilenames( ); protected: