[Insight-developers] Behavior of the Evaluate EvaluateAtContinuousIndex

Kwame Kutten kkutten1 at jhmi.edu
Mon Sep 13 09:54:58 EDT 2010


Hi Luis,

Thanks for your reply and drawings. You've presented an special case that I had not thought about until now.  Let's say we have a tiny 3x3 image. Double lines indicate the image boundaries. A, B and C represent pixels.

----o-------------o-------------o----
    |             |             |
    |  OUTSIDE    |             |
    |             |             |
    |             |             |
    |             |             |
    |             |             |
----O=============C=============O----
 O  ||            |            || O
 U  ||            |            || U
 T  ||            |            || T
 S  ||            |  INSIDE    || S
 I  ||            |            || I
 D  ||            |            || D
-E--o-------------B-------------o-E--
    ||            |            ||
    ||  INSIDE    |            ||
    ||            |            ||
    ||            |            ||
    ||            |            ||
    ||            |            ||
----O=============A=============O----
    |             |             |
    |             |             |
    |             |             |
    |   OUTSIDE   |             |
    |             |             |
----o-------------o-------------o----

If the WarpPadImageFilter was used, a nearest-neighbor interpolator would assign the value at A to point P.

----o-------------A-------------o----
    |             |             |
    |             |             |
    |             |             |
    |             |             |
    |             |             |
    |             |             |
----O=============C=============O----
    ||            |            ||
    ||            |            ||
    ||            |            ||
    ||            |            ||
    ||            |            ||
    ||            |            || 
----o-------------B-------------o----
    ||            |            ||
    ||            |            ||
    ||     XXXXXXXXXXXXXXX     ||
    ||     X      |      X     ||
    ||     X      |      X     ||
    ||     X      |      X     ||
----O======X======A======X======O----
    |      X      | P    X      |
    |      X      |      X      |
    |      XXXXXXXXXXXXXXX      |
    |             |             |
    |             |             |
----o-------------B-------------o----

But with my WrapExtrapolateImageFunction, point P would be wrapped around to P' and the nearest-neighbor interpolator would return the value at C. Technically, this behavior would be incorrect.


----o-------------o-------------o----
    |             |             |
    |  OUTSIDE    |             |
    |     YYYYYYYYYYYYYYYY      |
    |     Y       |      Y      |
    |     Y       |      Y      |
    |     Y       |      Y      |
----O=====Y=======C======Y======O----
 O  ||    Y       |  P'  Y     || O
 U  ||    Y       |      Y     || U
 T  ||    YYYYYYYYYYYYYYYY     || T
 S  ||            |  INSIDE    || S
 I  ||            |            || I
 D  ||            |            || D
-E--o-------------B-------------o-E--
    ||            |            ||
    ||  INSIDE    |            ||
    ||     XXXXXXXXXXXXXXX     ||
    ||     X      |      X     ||
    ||     X      |      X     ||
    ||     X      |      X     ||
----O======X======A======X======O----
    |      X      | P    X      |
    |      X      |      X      |
    |      XXXXXXXXXXXXXXX      |
    |   OUTSIDE   |             |
    |             |             |
----o-------------o-------------o---- 

- Kwame

----- Original Message -----
From: Luis Ibanez <luis.ibanez at kitware.com>
Date: Sunday, September 12, 2010 12:41 pm
Subject: Re: [Insight-developers] Behavior of the Evaluate EvaluateAtContinuousIndex
To: Kwame Kutten <kkutten1 at jhmi.edu>
Cc: insight-developers at itk.org


> Hi Kwame,
> 
> 
> I have tried to mentally picture the case that you are
> addressing, but haven't find an unambiguous way to do it.
> 
> Before we discuss how the case should be managed,
> we should make sure that we all understand the specific
> geometry of this particular case.
> 
> Please see below my attempt the graphically represent
> the case. This is for the bottom boundary of an image.
> The double line with the capita "O" represents the last
> row of pixels. Note that in ITK a Pixel is a sample point.
> 
> 
> 
>     |             |             |
>     |             |             |
> ----o-------------o-------------o-------
>     |             |             |
>     |             |             |
>     |   INSIDE    |             |
>     |             |             |
>     |             |             |
>     |             |             |
> ====O=============O=============O=======
>     |             |             |
>     |             |             |
>     |   OUTSIDE   |             |
>     |             |             |
>     |             |             |
>     |             |             |
> ----o-------------o-------------o-------
>     |             |             |
>     |             |             |
>     |             |             |
> 
> 
> If we were doing a nearest-neighborhood interpolation,
> we will say that it is valid to interpolate up to half-a-pixel
> around the pixel sample point.
> 
> 
> ----o-------------o-------------o-------
>     |             |             |
>     |   INSIDE    |             |
>     |      XXXXXXXXXXXXXXX      |
>     |      X      |      X      |
>     |      X      |      X      |
>     |      X      |      X      |
> ====O======X======A======X======O=======
>     |      X      |      X      |
>     |      X      |      X      |
>     |      XXXXXXXXXXXXXXX      |
>     |   OUTSIDE   |             |
>     |             |             |
> ----o-------------o-------------o-------
> 
> So, here, around the pixel "A", all the region denoted with
> X can be interpolated with a NN, and therefore all those
> points will have the same value as "A".
> 
> 
> Could you present your interpolation case in a
> similar schematic representation ?
> 
> 
> 
> Please let us know,
> 
> 
>          Thanks
> 
> 
>                Luis
> 
> 
> 
> --------------------------------------------
> On Fri, Sep 10, 2010 at 1:21 PM, Kwame Kutten <kkutten1 at jhmi.edu> wrote:
> 
> > I'm writing a WrapExtrapolateImageFunction for which the input index/point
> > is wrapped around if it lies outside the image.
> >
> > Basically its output would be the same as if the image was padded 
> using the
> > WrapPadImageFilter.
> >
> >
> >
> > How do you think the Evaluate() and EvaluateAtContinuousIndex() methods
> > should behave for a point or ContinousIndex that is outside the 
> image bounds
> > but between pixels?
> >
> >
> >
> > Currently, I pass an interpolator to the extrapolator...
> >
> >
> >
> >  typedef itk::WrapExtrapolateImageFunction<ImageType,double>
> >  ExtrapolatorType;
> >
> >  ExtrapolatorType::Pointer              extrapolator =
> > ExtrapolatorType::New();
> >
> >  extrapolator->SetInputImage(image);
> >
> >  extrapolator->SetInterpolator(interpolator);
> >
> >
> >
> >
> >
> > ...then the Evaluate() and EvaluateatContinuousIndex() methods wrap 
> the
> > ContinuousIndex or point around before evaluating its value with the
> > interpolator.
> >
> >
> >
> >  extrapolator->Evaluate(point);
> >
> >
> >
> > ...or...
> >
> >
> >
> >  extrapolator->EvaluateAtContinousIndex(cindex);
> >
> >
> >
> > Is this the best way to handle these cases?
> >
> > Thanks
> > _______________________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > 
> >
> > Kitware offers ITK Training Courses, for more information visit:
> > 
> >
> > Please keep messages on-topic and check the ITK FAQ at:
> > 
> >
> > Follow this link to subscribe/unsubscribe:
> > 
> >


More information about the Insight-developers mailing list