Hi Dan,<br><br>Thanks for pointing this out.<br><br>You are right, <br>as long as an Accessor is provided, <br>the ImageAdaptors should be able<br>to support Neighborhood iterators.<br><br>We may have to verify that all Neighborhood<br>
iterators (and operators) get to the image<br>values via the Accessor.<br><br><br>Could you please submit this patch<br>to Gerrit ?<br><br> <a href="http://review.source.kitware.com">http://review.source.kitware.com</a><br>
<br><br>    Many Thanks<br><br><br>           Luis<br><br><br>------------------------------------------------------------<br><div class="gmail_quote">On Sat, Oct 2, 2010 at 2:43 AM, Dan Mueller <span dir="ltr">&lt;<a href="mailto:dan.muel@gmail.com">dan.muel@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi all,<br>
<br>
I receive compilation errors when using ConstNeighborhoodIterator on<br>
an ImageAdaptor. Should I create a bug report? Is my fix below<br>
appropriate?<br>
<br>
Details: ITK 3.20, CMake 2.6.4, Visual Studio 2008, Windows XP.<br>
<br>
== CMakeLists.txt ==<br>
PROJECT(itkTest)<br>
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)<br>
FIND_PACKAGE(ITK REQUIRED)<br>
INCLUDE(${ITK_USE_FILE})<br>
INCLUDE_DIRECTORIES(<br>
  BEFORE<br>
  ${SOURCE_PATH}<br>
  ${TESTING_PATH}<br>
  )<br>
ADD_EXECUTABLE(Main main.cxx)<br>
TARGET_LINK_LIBRARIES(Main ${ITK_LIBRARIES})<br>
<br>
== main.cxx ==<br>
#if defined(_MSC_VER)<br>
#pragma warning ( disable : 4786 )<br>
#endif<br>
<br>
#define _SCL_SECURE_NO_WARNINGS<br>
<br>
#include &quot;itkImage.h&quot;<br>
#include &quot;itkImageAdaptor.h&quot;<br>
#include &quot;itkConstNeighborhoodIterator.h&quot;<br>
<br>
int main(int argc, char * argv [])<br>
{<br>
  try<br>
    {<br>
    // Typedefs<br>
    const unsigned int Dimension = 2;<br>
    typedef float PixelType;<br>
    typedef itk::Image&lt; PixelType, Dimension &gt; ImageType;<br>
    typedef itk::DefaultPixelAccessor&lt; PixelType &gt; DefaultPixelAccessorType;<br>
    typedef itk::ImageAdaptor&lt;ImageType, DefaultPixelAccessorType &gt; AdaptorType;<br>
    typedef itk::ConstNeighborhoodIterator&lt; AdaptorType &gt; IteratorType;<br>
<br>
    // Create image<br>
    ImageType::Pointer image = ImageType::New();<br>
    ImageType::RegionType::SizeType size; size.Fill(64);<br>
    ImageType::RegionType region(size);<br>
    image-&gt;SetRegions(region);<br>
    image-&gt;Allocate();<br>
    image-&gt;FillBuffer(128);<br>
<br>
    // Create adaptor around image<br>
    AdaptorType::Pointer adaptedImage = AdaptorType::New();<br>
    adaptedImage-&gt;SetImage(image);<br>
<br>
    // Create neighborhood iterator<br>
    IteratorType::SizeType radius; radius.Fill(2);<br>
    IteratorType it( radius, adaptedImage,<br>
adaptedImage-&gt;GetLargestPossibleRegion() );<br>
    for (it.GoToBegin(); !it.IsAtEnd(); ++it)<br>
      {<br>
      PixelType pixel0 = it.GetPixel(0);<br>
      PixelType pixel1 = it.GetPixel(1);<br>
      PixelType pixel2 = it.GetPixel(2);<br>
      }<br>
<br>
    return EXIT_SUCCESS;<br>
    }<br>
  catch (itk::ExceptionObject &amp; err)<br>
    {<br>
    std::cerr &lt;&lt; &quot;ExceptionObject caught !&quot; &lt;&lt; std::endl;<br>
    std::cerr &lt;&lt; err &lt;&lt; std::endl;<br>
    return EXIT_FAILURE;<br>
    }<br>
}<br>
<br>
== Selected compilation errors ==<br>
2&gt;Compiling...<br>
2&gt;main.cxx<br>
2&gt;c:\insighttoolkit-3.20.0\code\common\itkConstNeighborhoodIterator.h(89)<br>
: error C2039: &#39;NeighborhoodAccessorFunctorType&#39; : is not a member of<br>
&#39;itk::ImageAdaptor&lt;TImage,TAccessor&gt;&#39;<br>
2&gt;        with<br>
2&gt;        [<br>
2&gt;            TImage=ImageType,<br>
2&gt;            TAccessor=DefaultPixelAccessorType<br>
2&gt;        ]<br>
2&gt;        ..\main.cxx(36) : see reference to class template<br>
instantiation &#39;itk::ConstNeighborhoodIterator&lt;TImage&gt;&#39; being compiled<br>
2&gt;        with<br>
2&gt;        [<br>
2&gt;            TImage=AdaptorType<br>
2&gt;        ]<br>
2&gt;c:\insighttoolkit-3.20.0\code\common\itkConstNeighborhoodIterator.h(90)<br>
: error C2602: &#39;itk::ConstNeighborhoodIterator&lt;TImage&gt;::NeighborhoodAccessorFunctorType&#39;<br>
is not a member of a base class of<br>
&#39;itk::ConstNeighborhoodIterator&lt;TImage&gt;&#39;<br>
2&gt;        with<br>
2&gt;        [<br>
2&gt;            TImage=AdaptorType<br>
2&gt;        ]<br>
2&gt;        c:\insighttoolkit-3.20.0\code\common\itkConstNeighborhoodIterator.h(90)<br>
: see declaration of<br>
&#39;itk::ConstNeighborhoodIterator&lt;TImage&gt;::NeighborhoodAccessorFunctorType&#39;<br>
2&gt;        with<br>
2&gt;        [<br>
2&gt;            TImage=AdaptorType<br>
2&gt;        ]<br>
<br>
== Proposed fix: ImageAdaptor.h.patch ==<br>
C:\Temp\itkTest&gt;diff --text itkImageAdaptor.h itkImageAdaptor.h.new<br>
89a90,93<br>
&gt;<br>
&gt;   /** Typedef for the functor used to access a neighborhood of pixel<br>
&gt;    * pointers. */<br>
&gt;   typedef NeighborhoodAccessorFunctor&lt; Self &gt;  NeighborhoodAccessorFunctorType;<br>
283c287,295<br>
&lt;<br>
---<br>
&gt;<br>
&gt;   /** Return the NeighborhoodAccessor functor */<br>
&gt;   NeighborhoodAccessorFunctorType GetNeighborhoodAccessor()<br>
&gt;     { return NeighborhoodAccessorFunctorType(); }<br>
&gt;<br>
&gt;   /** Return the NeighborhoodAccessor functor */<br>
&gt;   const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() const<br>
&gt;     { return NeighborhoodAccessorFunctorType(); }<br>
&gt;<br></blockquote></div><br>