[Insight-users] (no subject)

Miller, James V (Research) millerjv at crd.ge.com
Thu Jan 13 11:22:58 EST 2005


Andre,

The pattern for establishing a boundary condition is to simply set the
boundary condition on the neighborhood iterator at runtime rather than 
establishing it a compile time. The code snippet below instantiates a 
boundary condition and a neighborhood iterator (without specifying a 
boundary condition at compile time).  The boundary condition is assigned 
to the neighborhood iterator using the OverrideBoundaryCondition() method.


    ZeroFluxNeumannBoundaryCondition<InputImageType> nbc;
    ConstNeighborhoodIterator<InputImageType> bit;
    bit = ConstNeighborhoodIterator<InputImageType>(radius,
                                                    input, *fit);
    bit.OverrideBoundaryCondition(&nbc);


Establishing the boundary condition at compile time is a known issue.  
I do not know whether it has been addressed.  But setting the boundary
condition at runtime is known to work.

Jim

-----Original Message-----
From: Andre Huisman [mailto:ahuisman at cs.uu.nl]
Sent: Thursday, January 13, 2005 10:33 AM
To: insight-users at itk.org
Cc: a.huisman-4 at lab.azu.nl
Subject: [Insight-users] (no subject)


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!
Andre Huisman
Department of pathology, University Medical Center Utrecht, the Netherlands
_______________________________________________
Insight-users mailing list
Insight-users at itk.org
http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list