[Insight-users] Face calculator

Christof Seiler christof.seiler at gmail.com
Thu Oct 11 09:49:48 EDT 2007


Hi Luis,
thanks for your quick response. Here my source code, part 1 is the image I
generate, and in part 2 this image is then used as the input image.

Part 1:
    ...
    ImageType::Pointer image = ImageType::New();
    // The image region should be initialized
    ImageType::IndexType start;
    ImageType::SizeType  size;
    size[0]  = imageSize[0];  // size along X
    size[1]  = imageSize[1];  // size along Y
    size[2]     = imageSize[2];
    start[0] =   0;  // first index on X
    start[1] =   0;  // first index on Y
    start[2] =   0;

    ImageType::RegionType region;
    region.SetSize( size );
    region.SetIndex( start );

    // Pixel data is allocated
    image->SetRegions( region );
    image->Allocate();

    ImageType::PixelType normalise = size[0]*size[0];
    for(int k = 0; k < size[2]; k++) {
        for(int j = 0; j < size[1]; j++) {
            for(int i = 0; i < size[0]; i++) {
                ImageType::IndexType index;
                index[0] = i; index[1] = j; index[2] = k;
                ImageType::PixelType elastic = i*i;
                elastic = elastic / normalise;
                elastic = elastic * maxDeform;
                elastic *= -1;
                image->SetPixel(index, elastic);
            }
        }
    }
    ...

Part 2:
    ...
    // build up neighborhood iteration stuff
    typename
NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<InputImageType>::FaceListType
faceList;
    NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<InputImageType> bC;
    ConstNeighborhoodIterator<InputImageType>::RadiusType radius;
    radius.Fill(1);
    faceList = bC(input, input->GetRequestedRegion(), radius);
    typename
NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<InputImageType>::FaceListType::iterator
fit;

    // TODO: Why are non-boundary not first element?
    fit = faceList.begin();
    //for(unsigned int i = 0; i < 6; i++) fit++;
    for(; fit != faceList.end(); ++fit) {
        ConstNeighborhoodIterator<InputImageType> bit(radius, input, *fit);

        // build up image iterator
        ImageRegionIterator<OutputImageType> out(output, *fit);

        // loop over neighborhoods and write to output image
        for(; !bit.IsAtEnd(); ++bit, ++out) {

            out.Set( bit.GetCenterPixel() );

        }
    }
    ...

Chris

On 10/11/07, Luis Ibanez <luis.ibanez at kitware.com> wrote:
>
>
> Hi Christof,
>
> Can you post to the list a minimum source code example illustrating
> this behavior ?
>
> It sounds like a bug, but we need a way to reproduce it in order
> to track any potential problem.
>
>
>     Thanks
>
>
>        Luis
>
>
> ------------------------
> Christof Seiler wrote:
> > Hi all,
> > I want to use the NeighborhoodAlgorithm::ImageBoundaryFacesCalculator
> > class but I ran into the following problem.
> >
> > I call:
> > ...
> > faceList = faceCalculator(input, input->GetRequestedRegion(), radius);
> > ...
> > and in the user's guide it says:
> > "The first element in the list is always the inner region, which may or
> > may not be important depending on the application."
> >
> > but in fact I get boundary faces first and the non-boundary element is
> > in last position.
> >
> > What am I missing?
> > Thanks in advance.
> > Chris
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users at itk.org
> > http://www.itk.org/mailman/listinfo/insight-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20071011/614c0f43/attachment.html


More information about the Insight-users mailing list