[Insight-users] index problem

Lydia Ng lng at insightful.com
Thu, 8 Jan 2004 11:22:42 -0800


Hi Corinne,

Would you mind posting some code that illustrates this problem?
I.e. how the various filter is being used.
I am curious if the problem lies with the indexing or the interaction =
between
the filters or if some fundamental assumption were made in the algorithm =
that
assume zero starting index.

Thanks,
Lydia


> -----Original Message-----
> From: Corinne Mattmann [mailto:mattmaco at ee.ethz.ch]
> Sent: Tuesday, January 06, 2004 4:26 PM
> To: 'Luis Ibanez'
> Cc: insight-users at itk.org
> Subject: RE: [Insight-users] index problem
>=20
> Hi Luis,
>=20
> 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?
>=20
> Thanks very much for your answer and have a nice evening,
> Corinne
>=20
>=20
> -----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
>=20
>=20
>=20
> Hi Corinne
>=20
> What is the goal that you pursue by resizing the image ?
>=20
>=20
> A) Do you want to have as a result the same image
>     with an additional band of pixels around ?
>=20
>     or
>=20
> B) Do you simply want to get a larger size and
>     don't care about discarding the original
>     content of the image ?
>=20
> 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
>=20
>=20
> 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...
>=20
>=20
> The code will look like:
>=20
>    // get the original image
>    ImageType::ConstPointer image1 =3D GetImageSomehow();
>=20
>    // prepare new size
>    ImageType::SizeType  size;
>    ImageType::IndexType start;
>    ImageType::RegionType  region;
>=20
>    size[0] =3D 512;  // new image size
>    size[1] =3D 512;
>    size[2] =3D 512;
>=20
>    start[0] =3D 0;  // or maybe start somewhere else... ?
>    start[1] =3D 0;
>    start[2] =3D 0;
>=20
>    region.SetSize( size );
>    region.SetIndex( start );
>=20
>    ImageType::Pointer image2 =3D ImageType::New();
>=20
>    // copy origin and spacing
>    image2->CopyInformation( image1 );
>=20
>    image2->SetRegions( region );
>    image2->Allocate();
>=20
>=20
>=20
> 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.
>=20
> Any subsequent call to Update() on the filter will
> reset the content of the image and override your
> modifications.
>=20
>=20
>=20
> Please let us know if you have further questions,
>=20
>=20
>   Thanks
>=20
>=20
>     Luis
>=20
>=20
>=20
> --------------------------
> Corinne Mattmann wrote:
>=20
> > 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] =3D {0,0,0};
> > 	index.SetIndex(in);
> > 	const unsigned long si[3] =3D {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
> >
>=20
>=20
>=20
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users