[Insight-developers] ImageAdaptors, PixelAccessors and Neighborhood iterators
Luis Ibanez
luis . ibanez at kitware . com
Tue, 28 Oct 2003 12:02:52 -0500
This is a multi-part message in MIME format.
--------------040104090402030908070001
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Hi Josh,
I'm tracking down a problem reported in the users-list
concerning the use of the Laplacian filter over an image
connected to an ImageAdaptor.
The bottom line seems to be that the Neighborhood iterators
do not support the use of ImageAdaptos and PixelAccessors.
I understand that some performance issues may be involved,
nonetheless, I gave it a shoot and got a set of modification
that allow me to compile the Laplacian filter with an adaptor.
Before going too far I would like to get your opinion on
how invasive this could be, and how bad could it affect
performance.
The CVS diffs for these changes are at the end of this email.
Please let me know what you think about these potential
changes.
Thanks
Luis
---------------------
--------------040104090402030908070001
Content-Type: text/plain;
name="NeighborhoodIteratorsAndAdaptors.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="NeighborhoodIteratorsAndAdaptors.txt"
Index: itkConstNeighborhoodIterator.h
===================================================================
RCS file: /cvsroot/Insight/Insight/Code/Common/itkConstNeighborhoodIterator.h,v
retrieving revision 1.29
diff -r1.29 itkConstNeighborhoodIterator.h
59a60
> typedef typename TImage::AccessorType AccessorType;
82c83
< typedef Neighborhood<PixelType, itkGetStaticConstMacro(Dimension)> NeighborhoodType;
---
> typedef Neighborhood<InternalPixelType, itkGetStaticConstMacro(Dimension)> NeighborhoodType;
138c139
< { return *( this->GetCenterPointer() ); }
---
> { PixelType value; m_PixelAccessor.Get(*( this->GetCenterPointer()), value); return value; }
462a464,467
>
>
> /** Pixel Accessor Type taken from the ImageType. It will support ImageAdaptors */
> AccessorType m_PixelAccessor;
Index: itkConstNeighborhoodIterator.txx
===================================================================
RCS file: /cvsroot/Insight/Insight/Code/Common/itkConstNeighborhoodIterator.txx,v
retrieving revision 1.20
diff -r1.20 itkConstNeighborhoodIterator.txx
50c50
< return (*(this->operator[](n)));
---
> return m_PixelAccessor.Get( *(this->operator[](n)) );
61c61
< return (*(this->operator[](n)));
---
> return m_PixelAccessor.Get( *(this->operator[](n)) );
97c97
< return ( *(this->operator[](n)) ) ;
---
> return m_PixelAccessor.Get( *(this->operator[](n)) );
101c101
< return( m_BoundaryCondition->operator()(temp, offset, this) );
---
> return( m_PixelAccessor.Get( m_BoundaryCondition->operator()(temp, offset, this) ));
170a171
> m_PixelAccessor = orig.m_PixelAccessor;
321a323,324
> m_PixelAccessor = ptr->GetPixelAccessor();
>
369a373
> m_PixelAccessor = orig.m_PixelAccessor;
Index: itkImageBoundaryCondition.h
===================================================================
RCS file: /cvsroot/Insight/Insight/Code/Common/itkImageBoundaryCondition.h,v
retrieving revision 1.10
diff -r1.10 itkImageBoundaryCondition.h
63c63
< typedef typename TImageType::PixelType PixelType;
---
> typedef typename TImageType::InternalPixelType PixelType;
81a82
>
Index: itkNeighborhoodIterator.h
===================================================================
RCS file: /cvsroot/Insight/Insight/Code/Common/itkNeighborhoodIterator.h,v
retrieving revision 1.46
diff -r1.46 itkNeighborhoodIterator.h
240c240
< { *( this->GetCenterPointer() ) = p; }
---
> { m_PixelAccessor.Set(*( this->GetCenterPointer()), p ); }
Index: itkNeighborhoodIterator.txx
===================================================================
RCS file: /cvsroot/Insight/Insight/Code/Common/itkNeighborhoodIterator.txx,v
retrieving revision 1.24
diff -r1.24 itkNeighborhoodIterator.txx
31c31
< { *(this->operator[](n)) = v; }
---
> { m_PixelAccessor.Set( *(this->operator[](n)), v ); }
34c34
< else if (this->InBounds()) *(this->operator[](n)) = v;
---
> else if (this->InBounds()) { m_PixelAccessor.Set(*(this->operator[](n)), v ); }
72c72
< *(this->operator[](n)) = v;
---
> m_PixelAccessor.Set( *(this->operator[](n)), v );
94c94
< *(this->operator[](n)) = v;
---
> m_PixelAccessor.Set( *(this->operator[](n)), v );
100c100
< *(this->operator[](n)) = v;
---
> m_PixelAccessor.Set( *(this->operator[](n)), v );
125c125
< *(this->operator[](n)) = v ;
---
> m_PixelAccessor.Set( *(this->operator[](n)), v );
--------------040104090402030908070001--