]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Wed, 27 Sep 2017 21:40:53 +0000 (16:40 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Wed, 27 Sep 2017 21:40:53 +0000 (16:40 -0500)
lib/ivq/ITK/RegionOfInterestWithPaddingImageFilter.h [new file with mode: 0644]
lib/ivq/ITK/RegionOfInterestWithPaddingImageFilter.hxx [new file with mode: 0644]
lib/ivq/Qt/DicomSeriesSelectorDialog.cxx
lib/ivq/Qt/DicomSeriesSelectorDialog.h

diff --git a/lib/ivq/ITK/RegionOfInterestWithPaddingImageFilter.h b/lib/ivq/ITK/RegionOfInterestWithPaddingImageFilter.h
new file mode 100644 (file)
index 0000000..4828d8f
--- /dev/null
@@ -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 <itkRegionOfInterestImageFilter.h>
+
+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 <ivq/ITK/RegionOfInterestWithPaddingImageFilter.hxx>
+#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 (file)
index 0000000..14d1f0e
--- /dev/null
@@ -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$
index 6e39f344742bedbc80c7693f69992c84df321fde..c3248eded7bf220775eae872d8d9113912b9f882 100644 (file)
@@ -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( )
index 973dbcc4ef36c519049531ae2a3cfa02c2923676..ac64b166dcd068c7b21259ab05655c7cd1ed2ee5 100644 (file)
@@ -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: