[Insight-users] (no subject)

André Huisman ahuisman at cs.uu.nl
Thu Jan 13 10:33:20 EST 2005


Dear ITK-users,

For a certain algorithm I want to use a ConstHeighborhoodIterator using
the following code. However, it does not compile. If I remove the
BoundaryConditionType everything works fine, but if I have it (and I need
it!) I get the following compiler error (Microsoft Visual C++ 7):
TextureFeatureComputations.cpp(532) : error C2664:
'itk::NeighborhoodInnerProduct<TImage>::OutputPixelType
itk::NeighborhoodInnerProduct<TImage>::operator ()(const
itk::NeighborhoodInnerProduct<TImage>::NeighborhoodType &,const
itk::NeighborhoodInnerProduct<TImage>::OperatorType &) const' :
cannot convert parameter 1 from 'NeighborhoodIterType' to 'const
itk::NeighborhoodInnerProduct<TImage>::NeighborhoodType &'
        with
        [
            TImage=ImageType8
        ]
        and
        [
            TImage=ImageType8
        ]
        Reason: cannot convert from 'NeighborhoodIterType' to 'const
itk::NeighborhoodInnerProduct<TImage>::NeighborhoodType'
        with
        [
            TImage=ImageType8
        ]
        No constructor could take the source type, or constructor overload
resolution was ambiguous

My code is as follows:

typedef itk::ConstantBoundaryCondition<ImageType8> BoundaryConditionType;
typedef itk::ConstNeighborhoodIterator<ImageType8, BoundaryConditionType>
NeighborhoodIterType;
itk::NeighborhoodInnerProduct<ImageType8> innerProduct;
BoundaryConditionType boundaryCondition;

//Initialize kernel
NeighborhoodIterType::NeighborhoodType kernel;
kernel.SetRadius(1);
for(int i=0; i< std::pow(2*r + 1,ImageType8::GetImageDimension()); i++)
    kernel[i] = 1;

int sum_n = 0;
ImageType8::Pointer image= cell->mask;
NeighborhoodIterType neighborIterImg(kernel.GetRadius(), image,
image->GetLargestPossibleRegion());

//Padd black pixels to the border of the image.
boundaryCondition.SetConstant(0);
neighborIterImg.OverrideBoundaryCondition(&boundaryCondition);

for(neighborIterImg.GoToBegin(); !neighborIterImg.IsAtEnd();
++neighborIterImg)
        sum_n += innerProduct(neighborIterImg, kernel);


If somebody could help me, please react!

Thank you very very much!
André Huisman
Department of pathology, University Medical Center Utrecht, the Netherlands


More information about the Insight-users mailing list