[Insight-users] index problem

Luis Ibanez luis.ibanez at kitware.com
Wed, 07 Jan 2004 09:02:37 -0500


Hi Corinne,

If what you want is to make the image smaller,
that's equivalent to extract a region of interest
from the original image.

For that purpose you can use the filters:


- RegionOfInterestImageFilter
http://www.itk.org/Insight/Doxygen/html/classitk_1_1RegionOfInterestImageFilter.html


- ExtractImageFilter
http://www.itk.org/Insight/Doxygen/html/classitk_1_1ExtractImageFilter.html


They are described in the SoftwareGuide:


    http://www.itk.org/ItkSoftwareGuide.pdf


in Section 7.4 pdf-page 225 and Section 7.5, pdf-page 228,
respectively.


---------

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
> 
> 
> -----Original Message-----
> From: Luis Ibanez [mailto:luis.ibanez at kitware.com] 
> Sent: Tuesday, January 06, 2004 4:48 PM
> To: Corinne Mattmann
> Cc: insight-users at itk.org
> Subject: Re: [Insight-users] resize image
> 
> 
> 
> Hi Corinne
> 
> What is the goal that you pursue by resizing the image ?
> 
> 
> A) Do you want to have as a result the same image
>     with an additional band of pixels around ?
> 
>     or
> 
> B) Do you simply want to get a larger size and
>     don't care about discarding the original
>     content of the image ?
> 
> If you are in case (A) you may want to use the PasteImageFilter
> http://www.itk.org/Insight/Doxygen/html/classitk_1_1PasteImageFilter.htm
> l
> 
> 
> If you are in case (B) the best way to go is simply
> to create a new image. You could recover the origin
> and spacing information from the original image...
> but you have to think twice if the origin should be
> conserved or should be shifted...
> 
> 
> The code will look like:
> 
>    // get the original image
>    ImageType::ConstPointer image1 = GetImageSomehow();
> 
>    // prepare new size
>    ImageType::SizeType  size;
>    ImageType::IndexType start;
>    ImageType::RegionType  region;
> 
>    size[0] = 512;  // new image size
>    size[1] = 512;
>    size[2] = 512;
> 
>    start[0] = 0;  // or maybe start somewhere else... ?
>    start[1] = 0;
>    start[2] = 0;
> 
>    region.SetSize( size );
>    region.SetIndex( start );
> 
>    ImageType::Pointer image2 = ImageType::New();
> 
>    // copy origin and spacing
>    image2->CopyInformation( image1 );
> 
>    image2->SetRegions( region );
>    image2->Allocate();
> 
> 
> 
> The error message that you are getting seem
> to indicate that you are trying to call SetRegions()
> in a ConstPointer. Const-ness will not allow you
> to modify the regions of an image.  Note also that
> you don't want to do this on the output of a filter
> since the image is owned and controled by the filter.
> 
> Any subsequent call to Update() on the filter will
> reset the content of the image and override your
> modifications.
> 
> 
> 
> Please let us know if you have further questions,
> 
> 
>   Thanks
> 
> 
>     Luis
> 
> 
> 
> --------------------------
> Corinne Mattmann wrote:
> 
> 
>>Hi,
>>
>>I would like to resize my image (index and size). What's the easiest 
>>way to do this? I tried something like this:
>>
>>	typedef ImageRegion<ImageDimension> ImageRegionType;
>>	ImageRegionType region;
>>	typedef Index<ImageDimension> IndexType;
>>	IndexType index;
>>	typedef Size<ImageDimension> SizeType;
>>	SizeType size;
>>	const long in[3] = {0,0,0};
>>	index.SetIndex(in);
>>	const unsigned long si[3] = {50,50,50};
>>	size.SetSize(si);
>>	region.SetIndex(index);
>>	region.SetSize(size);
>>	image->SetRegions(region);
>>
>>But I got the following error:
>>
>>	error C2663: 'SetRegions' : 2 overloads have no legal conversion
> 
> for 
> 
>>'this' pointer
>>
>>
>>Thanks very much,
>>Corinne Mattmann
>>
>>_______________________________________________
>>Insight-users mailing list
>>Insight-users at itk.org 
>>http://www.itk.org/mailman/listinfo/insight-users
>>
> 
> 
> 
> 
>