The resulting image has the same size as the input image. Thus, if
surface is (partially) outside the input image, it will also be
(partially) outside the output image. The reason that you need to
provide an input image at all, is that we must somehow to determine the
pixeltype, dimension, spacing the output image shall have - the easiest
way to do that was just to provide an input image as example... This
input image needs to be initialized, but does not need to contain a data
vector.
To create an image of the same size as the surface, use the following
Initialize() variant of mitk::Image:
http://www.mitk.org/documentation/doxygen/classmitk_1_1Image.html#a20
mitk::Image::Pointer image = mitk::Image::New();
image->Initialize(PixelType(unsigned char), *surface->GetGeometry3D());
This image will have unit spacing. You can change this by image->SetSpacing.
Now it should be possible to use it with mitk::SurfaceToImageFilter.
Best regards,
Ivo
guoyanmin wrote:
> one question also, if i use mitk::SurfaceToImageFilter, i need not to
> think about the different coordinate systems between surface and
> image, i need only image and surface as input to this filter?
>
> best regards
>
>
>
> > Date: Wed, 6 Aug 2008 13:00:46 +0200
> > From: [EMAIL PROTECTED]
> > To: [EMAIL PROTECTED]
> > CC: [email protected]
> > Subject: Re: [mitk-users] problem about the surface and image
> >
> > Hi,
> > your code snippet looks like you want to convert a surface to an image,
> > is this correct? MITK has a filter for that purpose - which does more or
> > less the same as you do, i.e., using vtk stenciling:
> > mitk::SurfaceToImageFilter. If you tried it and it did not work as you
> > expected, please tell us ...
> > For more information, see
> >
> http://www.mitk.org/documentation/doxygen/classmitk_1_1SurfaceToImageFilter.html
> >! Best regards,
> > Ivo
> >
> > guoyanmin wrote:
> > > thank you so much for your quickly answer,but i have used the
> > > transformfilter from the index coordinates system to the world
> > > coordinate system, i have writed
> > >
> > > TimeSlicedGeometry *surfaceTimeGeometry =
> > > surface->GetTimeSlicedGeometry();
> > >
> > > TimeSlicedGeometry *imageTimeGeometry = img->GetTimeSlicedGeometry();
> > >
> > > Geometry3D* imageGeometry = imageTimeGeometry->GetGeometry3D(0);
> > >
> > > vtkPolyData * polydata = surface->GetVtkPolyData( );
> > >
> > > Geometry3D* surfacegeometry = surfaceTimeGeometry->GetGeometry3D(0);
> > >
> > > vtkLinearTransform *transform = surfacegeometry->GetVtkTransform();
> > >
> > > vtkTransformPolyDataFilter *
> > > transformFilter=vtkTransformPolyDataFilter::New(); *
> > > transfor! mFilter->SetInput(polydata);
> > >
> > > tran! sformFil ter->SetTransform(transform);
> > >
> > > transformFilter->Update();
> > >
> > > vtkPolyDataToImageStencil * dataToStencil=
> > > vtkPolyDataToImageStencil::New();
> > >
> > > dataToStencil->SetInput( transformFilter->GetOutput());
> > >
> > > *
> > >
> > > * vtkImageStencil * stencil = vtkImageStencil::New();*
> > >
> > > ** * stencil->SetStencil(dataToStencil->GetOutput());*
> > >
> > > * stencil->SetBackgroundValue( 0 );*
> > >
> > > * stencil->ReverseStencilOff();*
> > >
> > > * vtkImageData *vtkimage = image->GetVtkImageData();*
> > >
> > > * stencil->SetInput( vtkimage );*
> > >
> > > * stencil->Update();*
> > >
> > > * vtkimage = stencil->GetOutput();*
> > >
> > > * mitk::Image::Pointer m_img;*
> > >
> > > * m_img->Initialize(vtki! mage);*
> > >
> > > * m_img->SetVolume( vtkimage->GetScalarPointer() );*
> > >
> > > *
> > > *
> > >
> > > *and this m_img is the new cut image, what i want.but it shows not in
> > > the right position. can you give me some ideas.*
> > >
> > > *
> > > *
> > >
> > > *
> > > *
> > >
> > > *& nbsp;
> > > *
> > >
> > > * *
> > >
> > > *
> > > *
> > >
> > > **
> > >
> > > * *
> > >
> > > *
> > > *
> > >
> > > *
> > >
> > > *
> > >
> ------------------------------------------------------------------------
> > > *Subject: AW: [mitk-users] problem about the surface and image
> > > Date: Wed, 6 Aug 2008 12:04:50 +0200
> > > From: [EMAIL PROTECTED]
> > > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] forge.net
> > >
> > > *
> > >
> > >! ; *Hi Ja cob,*
> > >
> > > *did you possible use the coordinates of the surface to cut the image
> > > and not the world coordinates of the surface?*
> > >
> > > * *
> > >
> > > *You will have to transform the surface coordinates (this way the
> > > transform to the center is also considered) to world coordinates and
> > > then to the coordinate space of the image to get the right positions.*
> > >
> > > * *
> > >
> > > *Regards,*
> > >
> > > *Ingmar*
> > >
> > > * *
> > >
> > > *Dipl.-Inform. Med. Ingmar Wegner
> > > DKFZ
> > > German Cancer Research Center (Deutsches Krebsforschungszentrum)
> > > Member of the Helmholtz Association
> > > Division Medical and Biological Informatics E130
> > > Im Neuenheimer Feld 280
> > > D-69120 Heidelberg*
> > >
> > > *Phone: 49-(0)6221-42-3543
> > > Fax:! 49-(0)6221-42-2345
> > > E-Mail: [EMAIL PROTECTED]
> > > Web: www.dkfz.de*
> > >
> > > * *
> > >
> > > *Confidentiality Note: This message is intended only for the use of
> > > the named recipient(s) and may obtain confidential and/or privileged
> > > information. If you are not the intended recipient, please contact the
> > > sender and delete the message. Any unauthorized use of the information
> > > contained in this message is prohibited. *
> > >
> > > * *
> > >
> > > **Von:* [EMAIL PROTECTED]
> > > [mailto:[EMAIL PROTECTED] *Im Auftrag von
> > > *guoyanmin
> > > *Gesendet:* Mittwoch, 6. August 2008 11:36
> > > *An:* [email protected]
> > > *Betreff:* [mitk-users] problem about the surface and image*
> > >
> > > * *
> > >
> > > *hallo everyone, i have! one question long times.
> > > now i want to use the s! urface t o cut one image, i load the
> surface and
> > > image, for example this surface stay upper-left of image, i move this
> > > surface to the center of image, and cut this image, but this part of
> > > cut image is showed only upper-left position, that means, only in the
> > > position, where i load the surface.
> > > anybody can tell me, how i can put this cut image in the center of
> > > image, but not in the upper-left position.
> > >
> > > best regards
> > >
> > > *
> > >
> > >
> ------------------------------------------------------------------------
> > >
> > > *使用新一代** Windows Live Messenger **轻松交流和共享!** **立即体验!
> > > <http://messenger.live.cn/>*
> > >
> > > *
> > > *
> > >
> ------------------------------------------------------------------------
> > > *用 Windows Live Spaces 展示个性自我,与好友分享生活! 了解更多!
> 信息!
> > > <http://spaces.live.com/?page=HP>*
> > > *
> > > *
> > >
> ------------------------------------------------------------------------
> > > *
> > >
> -------------------------------------------------------------------------
> > > This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> > > Build the coolest Linux based applications with Moblin SDK & win
> great prizes
> > > Grand prize is a trip for two to an Open Source event anywhere in
> the world
> > > http://moblin-contest.org/redirect.php?banner_id=100&url=/*
> > > *
> > > *
> > >
> ------------------------------------------------------------------------
> > > *
> > > _______________________________________________
> > > mitk-users mailing list
> > > [email protected]
> > > https://lists.sourceforge.net/lists/listinfo/mitk-users
> > > *!
> >
> >
> > --
> > -----------------------! --------
> ---------------------------------------
> > Dr. Ivo Wolf, Dipl.-Phys. Phone: (+49) 6221/42-2327
> > Deutsches Krebsforschungszentrum Fax: (+49) 6221/42-2345
> > Div. Medical and Biological Informatics (E130)
> > Im Neuenheimer Feld 280 email: [EMAIL PROTECTED]
> > D-69120 Heidelberg, Germany http://mbi.dkfz-heidelberg.de
> > ----------------------------------------------------------------------
> > Confidentiality Note: This message is intended only for the use of the
> > named
> > recipient(s) and may obtain confidential and/or privileged information.
> > If you
> > are not the intended recipient, please contact the sender and delete the
> > message.
> > Any unauthorized use of the information contained in this message is
> > prohibited.
> >
>
> ------------------------------------------------------------------------
> 使用新一代 Windows Live Messenger 轻松交流和共享! 立即体验!
> <http://messenger.live.cn/>
--
----------------------------------------------------------------------
Dr. Ivo Wolf, Dipl.-Phys. Phone: (+49) 6221/42-2327
Deutsches Krebsforschungszentrum Fax: (+49) 6221/42-2345
Div. Medical and Biological Informatics (E130)
Im Neuenheimer Feld 280 email: [EMAIL PROTECTED]
D-69120 Heidelberg, Germany http://mbi.dkfz-heidelberg.de
----------------------------------------------------------------------
Confidentiality Note: This message is intended only for the use of the
named
recipient(s) and may obtain confidential and/or privileged information.
If you
are not the intended recipient, please contact the sender and delete the
message.
Any unauthorized use of the information contained in this message is
prohibited.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users