[IGSTK-Users] problems using a specific image reader

Patrick Cheng cheng at isis.georgetown.edu
Tue Mar 20 10:31:30 EDT 2007


Hi Sophie,

Good to hear that it works out for you.

Patrick

Sophie Blestel wrote:
> Hi,
> 
> .GetPointer()  works, I did a mistake yesterday...
> 
> And the call to
>       
> igstk::Friends::ImageReaderToImageSpatialObject::ConnectImage(m_ImageReader,
>             m_ImageSpatialObject.GetPointer());
> works !
> Thanks a lot !
> 
> Sophie
> 
> 
> 2007/3/19, Patrick Cheng <cheng at isis.georgetown.edu 
> <mailto:cheng at isis.georgetown.edu>>:
> 
>     Hi Sophie,
> 
>     The .GetPointer() comes from smart pointer, it should work with any
>     ImageSpatialObject. What's the error message when you try to call this
>     method?
> 
>     Patrick
> 
>     Sophie Blestel wrote:
>      > Hi Patrick,
>      >
>      > I've tried the "2." but GetPointer() is not a member of the class
>      > MRImageSpatialObject.
>      > I 'll try the  1. tomorrow, I told  you then.
>      >
>      > Thank you,
>      >
>      > Sophie
>      >
>      > 2007/3/19, Patrick Cheng <cheng at isis.georgetown.edu
>     <mailto:cheng at isis.georgetown.edu>
>      > <mailto:cheng at isis.georgetown.edu
>     <mailto:cheng at isis.georgetown.edu>>>:
>      >
>      >     Hi Sophie,
>      >
>      >     To read an ITK image and pass it to igstkImageSpatialObject
>     you can do
>      >     the following two things:
>      >
>      >     1. IGSTK use loaded events to pass image data around. We use
>     observer to
>      >     observe image reader, and call RequestGetImage() to ask the image
>      >     reader
>      >     to send out the event. Some sample code as following:
>      >
>      >        igstkObserverObjectMacro(CTImage,CTImageReader::ImageModifiedEvent,
> 
>      >                                                        CTImageSpatialObject)
>      >
>      >        m_CTImageObserver = CTImageObserver::New();
>      >
>      >    
>     m_ImageReader->AddObserver(igstk::CTImageReader::ImageModifiedEvent(),
>      >                                   m_CTImageObserver);
>      >
>      >          m_ImageReader->RequestReadImage();
>      >
>      >          m_ImageReader->RequestGetImage();
>      >
>      >          if(m_CTImageObserver->GotCTImage())
>      >            {
>      >            m_ImageSpatialObject = m_CTImageObserver->GetCTImage();
>      >            }
>      >
>      >
>      >     2. If you don't want to use observer, try add a .GetPointer()
>     to your
>      >     code see if it will work.
>      >
>      >    
>     igstk::Friends::ImageReaderToImageSpatialObject::ConnectImage(m_ImageReader,
>      >
>      >       m_ImageSpatialObject.GetPointer());
>      >
>      >
>      >     Patrick
>      >
>      >
>      >     Sophie Blestel wrote:
>      >      > Hi,
>      >      >
>      >      > I use images in a specific format, so I can't read them using
>      >      > DICOMImageReader. So I have written a new class :
>     GisImageReader,
>      >     that
>      >      > has only a few methods :
>      >      >
>      >      >        //to set my image in an internal variable
>      >      >        void SetGisImage(char * FileName);
>      >      >
>      >      >        //to get my image as an itk::OrientedImage
>      >      >        const virtual ImageType::ConstPointer GetITKImage()
>     const;
>      >      >        (with : typedef itk::OrientedImage< unsigned short,
>     3 >
>      >     ImageType)
>      >      >
>      >      >        etc....
>      >      >
>      >      > This class doesn't inheritate.
>      >      >
>      >      > I have also  declared the ImageReaderToImageSpatialObject
>     class
>      >     to be a
>      >      > friend :
>      >      >
>      >      >        igstkFriendClassMacro(
>      >      > igstk::Friends::ImageReaderToImageSpatialObject );
>      >      >
>      >      > In my project, I do :
>      >      >
>      >      >        igstk::MRImageSpatialObject *  m_ImageSpatialObject =
>      >      > igstk::MRImageSpatialObject::New();
>      >      >        igstk::GisImageReader  *   m_ImageReader = new
>      >      > igstk::GisImageReader();
>      >      >
>      >      >        m_ImageReader->SetGisImage(FileName);
>      >      >
>      >      >
>      >    
>     igstk::Friends::ImageReaderToImageSpatialObject::ConnectImage(m_ImageReader,
> 
>      >
>      >      > m_ImageSpatialObject);
>      >      >
>      >      > ConnectImage is defined in igstkImageReader as follows :
>      >      >        template < class TReader, class TImageSpatialObject >
>      >      >        static void
>      >      >        ConnectImage( const TReader * reader,
>     TImageSpatialObject *
>      >      > imageSpatialObject )
>      >      >        {
>      >      >             cout<<"DEBUG, ConnectImage called ... \n";
>      >      >             imageSpatialObject->RequestSetImage(
>      >     reader->GetITKImage() );
>      >      >        }
>      >      >
>      >      > But when I execute it, there is an error : "Acces refused
>     / The
>      >     memory
>      >      > can't be read".
>      >      >
>      >      > This bug happends in the method :
>      >      >         ImageSpatialObject< TPixelType, VDimension
>      >      >::RequestSetImage(
>      >      > const ImageType * image )
>      >      > at it very beginning :
>      >      >          m_ImageToBeSet = image;
>      >      >
>      >      > Then I wrote :
>      >      >         (*image).Print(cout);
>      >      >         std::cout<<"m_ImageToBeSet"<<m_ImageToBeSet<<"\n";
>      >      >
>      >      > image is "full" and contains my image, but it appeared that
>      >      > m_ImageToBeSet induced an error, because it was not
>     initialized.
>      >      > So I initialized it in the constructor of the class
>      >     ImageSpatialObject,
>      >      > but it doesn't change anything. It still induces an error.
>      >      >
>      >      > Do you have any idea of what's wrong ?
>      >      >
>      >      > Thanks
>      >      >
>      >      >
>      >      >
>      >    
>     ------------------------------------------------------------------------
> 
>      >
>      >      >
>      >      > _______________________________________________
>      >      > IGSTK-Users mailing list
>      >      > IGSTK-Users at public.kitware.com
>     <mailto:IGSTK-Users at public.kitware.com>
>      >     <mailto:IGSTK-Users at public.kitware.com
>     <mailto:IGSTK-Users at public.kitware.com>>
>      >      >
>     http://public.kitware.com/cgi-bin/mailman/listinfo/igstk-users
>     <http://public.kitware.com/cgi-bin/mailman/listinfo/igstk-users>
>      >
>      >
> 
> 



More information about the IGSTK-Users mailing list