Hi, <br><br>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 : <br><br> //to set my image in an internal variable
<br> void <span style="font-weight: bold;">SetGisImage</span>(char * FileName); <br><br> //to get my image as an itk::OrientedImage<br> const virtual ImageType::ConstPointer <span style="font-weight: bold;">
GetITKImage()</span> const;<br> (with : typedef itk::OrientedImage< unsigned short, 3 > ImageType)<br><br> etc....<br><br>This class doesn't inheritate.<br><br>I have also declared the ImageReaderToImageSpatialObject class to be a friend :
<br> <br> igstkFriendClassMacro( igstk::Friends::ImageReaderToImageSpatialObject );<br><br>In my project, I do :<br><br> igstk::MRImageSpatialObject * m_ImageSpatialObject = igstk::MRImageSpatialObject::New();
<br> igstk::GisImageReader * m_ImageReader = new igstk::GisImageReader();<br><br> m_ImageReader->SetGisImage(FileName);<br> igstk::Friends::ImageReaderToImageSpatialObject::ConnectImage(m_ImageReader, m_ImageSpatialObject);
<br><br>ConnectImage is defined in igstkImageReader as follows :<br> template < class TReader, class TImageSpatialObject ><br> static void <br> ConnectImage( const TReader * reader, TImageSpatialObject * imageSpatialObject )
<br> {<br> cout<<"DEBUG, ConnectImage called ... \n";<br> imageSpatialObject->RequestSetImage( reader->GetITKImage() ); <br> }<br><br>But when I execute it, there is an error : "Acces refused / The memory can't be read".
<br><br>This bug happends in the method :<br> ImageSpatialObject< TPixelType, VDimension >::RequestSetImage( const ImageType * image ) <br>at it very beginning : <br> m_ImageToBeSet = image;<br><br>Then I wrote :
<br> (*image).Print(cout);<br> std::cout<<"m_ImageToBeSet"<<m_ImageToBeSet<<"\n"; <br><br>image is "full" and contains my image, but it appeared that m_ImageToBeSet induced an error, because it was not initialized.
<br>So I initialized it in the constructor of the class ImageSpatialObject, but it doesn't change anything. It still induces an error. <br><br>Do you have any idea of what's wrong ?<br><br>Thanks<br><br>