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"><<a href="mailto:dan.muel@gmail.com">dan.muel@gmail.com</a>></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 "itkImage.h"<br>
#include "itkImageAdaptor.h"<br>
#include "itkConstNeighborhoodIterator.h"<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< PixelType, Dimension > ImageType;<br>
typedef itk::DefaultPixelAccessor< PixelType > DefaultPixelAccessorType;<br>
typedef itk::ImageAdaptor<ImageType, DefaultPixelAccessorType > AdaptorType;<br>
typedef itk::ConstNeighborhoodIterator< AdaptorType > 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->SetRegions(region);<br>
image->Allocate();<br>
image->FillBuffer(128);<br>
<br>
// Create adaptor around image<br>
AdaptorType::Pointer adaptedImage = AdaptorType::New();<br>
adaptedImage->SetImage(image);<br>
<br>
// Create neighborhood iterator<br>
IteratorType::SizeType radius; radius.Fill(2);<br>
IteratorType it( radius, adaptedImage,<br>
adaptedImage->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 & err)<br>
{<br>
std::cerr << "ExceptionObject caught !" << std::endl;<br>
std::cerr << err << std::endl;<br>
return EXIT_FAILURE;<br>
}<br>
}<br>
<br>
== Selected compilation errors ==<br>
2>Compiling...<br>
2>main.cxx<br>
2>c:\insighttoolkit-3.20.0\code\common\itkConstNeighborhoodIterator.h(89)<br>
: error C2039: 'NeighborhoodAccessorFunctorType' : is not a member of<br>
'itk::ImageAdaptor<TImage,TAccessor>'<br>
2> with<br>
2> [<br>
2> TImage=ImageType,<br>
2> TAccessor=DefaultPixelAccessorType<br>
2> ]<br>
2> ..\main.cxx(36) : see reference to class template<br>
instantiation 'itk::ConstNeighborhoodIterator<TImage>' being compiled<br>
2> with<br>
2> [<br>
2> TImage=AdaptorType<br>
2> ]<br>
2>c:\insighttoolkit-3.20.0\code\common\itkConstNeighborhoodIterator.h(90)<br>
: error C2602: 'itk::ConstNeighborhoodIterator<TImage>::NeighborhoodAccessorFunctorType'<br>
is not a member of a base class of<br>
'itk::ConstNeighborhoodIterator<TImage>'<br>
2> with<br>
2> [<br>
2> TImage=AdaptorType<br>
2> ]<br>
2> c:\insighttoolkit-3.20.0\code\common\itkConstNeighborhoodIterator.h(90)<br>
: see declaration of<br>
'itk::ConstNeighborhoodIterator<TImage>::NeighborhoodAccessorFunctorType'<br>
2> with<br>
2> [<br>
2> TImage=AdaptorType<br>
2> ]<br>
<br>
== Proposed fix: ImageAdaptor.h.patch ==<br>
C:\Temp\itkTest>diff --text itkImageAdaptor.h itkImageAdaptor.h.new<br>
89a90,93<br>
><br>
> /** Typedef for the functor used to access a neighborhood of pixel<br>
> * pointers. */<br>
> typedef NeighborhoodAccessorFunctor< Self > NeighborhoodAccessorFunctorType;<br>
283c287,295<br>
<<br>
---<br>
><br>
> /** Return the NeighborhoodAccessor functor */<br>
> NeighborhoodAccessorFunctorType GetNeighborhoodAccessor()<br>
> { return NeighborhoodAccessorFunctorType(); }<br>
><br>
> /** Return the NeighborhoodAccessor functor */<br>
> const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() const<br>
> { return NeighborhoodAccessorFunctorType(); }<br>
><br></blockquote></div><br>