[Insight-users] index problem

Luis Ibanez luis.ibanez at kitware.com
Wed, 07 Jan 2004 11:59:06 -0500


Hi Corinne,

Thanks for your clarification, it makes
more sense now.


So, if your image LargestPossibleRegion()
has starting index = [3,1,1] the
MultiResolutionPyramidImageFilter computes
the starting index of the output image as

      outputStartIndex[idim] =
       static_cast<IndexValueType>(
              ceil( static_cast<double>(
                        inputStartIndex[idim])
                      / shrinkFactor ) );

[ taken from Insight/Code/Algorithms/
    itkMultiResolutionPyramideImageFilter.txx
  lines 408-409 ]

Which for a shrinkFactor == 2 comes down to

      ceil( 3.0 / 2 ) --> 2
      ceil( 1.0 / 2 ) --> 1
      ceil( 1.0 / 2 ) --> 1

so, a starting index of [2,1,1].


Now, when an image with starting index [2,1,1]
gets passed to the VectorExpandImageFilter it
produces an output image whose LargestPossible
Region has starting index [4,2,2].

The starting index of the output is computed in

Insight/Code/BasicFilters/
      itkVectorExpandImageFilter.txx

on lines 389-391

>    outputStartIndex[i] = (long)
>       ((ExpandFactorsType)inputStartIndex[i] * m_ExpandFactors[i]+
>        (ExpandFactorsType)0.5);

If this starting index is giving you trouble,
You may simply replace this filter with the

itkVectorResampleImageFilter
http://www.itk.org/Insight/Doxygen/html/classitk_1_1VectorResampleImageFilter.html

and use with it an IdentityTransform
http://www.itk.org/Insight/Doxygen/html/classitk_1_1IdentityTransform.html

since the scaling effect is simply controled by
defining the SetOutputSpacing() of the filter.

That is, in order to get an image of double the size,
you set the output spacing to be half of the input
spacing.



Please let us know if you have further questions.



Thanks



     Luis



----------------------------
Corinne Mattmann wrote:

> Hi Luis,
> 
> With index I mean the starting point of the image.
> I check the index with making a cout of
> pyramid->GetOutput(CurrentLevel)->GetLargestPossibleRegion() (or
> GetRequestedRegion(), it's the same in my case)
> and get the three parameters "Dimension", "Index" and "Size".
> 
> Sorry for not asking the question clearly,
> Corinne
> 
> 
> -----Original Message-----
> From: Luis Ibanez [mailto:luis.ibanez at kitware.com] 
> Sent: Wednesday, January 07, 2004 7:03 AM
> To: Corinne Mattmann
> Cc: insight-users at itk.org
> Subject: Re: [Insight-users] index problem
> 
> 
> ---------
> 
> About your index question,
> 
> It is not clear what you mean by
> 
>     "I have and image with index [3,1,1]"
> 
> is that the "size" of the image ?
> 
> or are you making reference to one pixel
> in the image that is located at index [3,1,1] ?
> 
> Could you please rephrase the question to
> give us a better idea of the problem you
> are facing ?
> 
> Or maybe post a minimal code example that
> illustrates the problem...
> 
> 
> Thanks
> 
> 
> 
>    Luis
> 
> 
> 
> ------------------------
> Corinne Mattmann wrote:
> 
>>Hi Luis,
>>
>>Thanks for your answer. I would like to make my image smaller with the
> 
> 
>>same content (cut some pixels away at the border and set another 
>>index), so I think A) should work. At the moment I have another 
>>questions: I am programming a filter which registers two images with 
>>the demons algorithm using a multi-resolution pyramid. To set up the 
>>pyramid I'm using itkRecursiveMultiResolutionPyramidImageFilter.
>>If I have an image with index [3,1,1] and if I reduce it by a factor
> 
> of
> 
>>2, the output of the pyramid would be an image with index [2,1,1].
>>This images I input into the demons-filter and get as output a
>>deformable field with the same index. So far so good.
>>But if I now expand this deformable field with the
>>itkVectorExpandImageFilter, I get an image with index [4,2,2], which
>>results in an error when I apply it to the images with index [3,1,1].
>>Took me quite long to find this problem ;-)
>>I wanted to set the "right" index at the expand filter but I couldn't
>>find an appropriate function. What solution do you suggest?
>>
>>Thanks very much for your answer and have a nice evening, Corinne
>>
>>
> 
> 
> 
>