On 03/12/2010 07:23 AM, apollocarlos wrote:
> Dear All,
> I am new to MITK. Now i'm trying to create a new, NULL mitk::image for
> contouring, as a mask on the images which are just read in. I tried like
> blow:
> mitk::Image::Pointer m_maskImage = mitk::Image::New();
> but when i tried to use GetPic() or GetGeometry(), it says the
> 0x00000000 memory can't be read.
> Could anyone help me?


Hi,

for a usable image, you have to call Initialize on the new mitk::Image. 
This tells the image about the dimensions and the pixel type. Not that 
the memory is only allocated, not initialized. A piece of code that 
initializes an image of the same dimensions as a "template image" would 
look like this:

mitk::Image::Pointer
CreateEmptySegmentationNode( Image* original )
{
   if (!original) return NULL;

   // actually create a new empty segmentation
   PixelType pixelType( typeid(unsigned char) );
   Image::Pointer segmentation = Image::New();

   segmentation->Initialize( pixelType,
                             original->GetDimension(),
                             original->GetDimensions() );

   unsigned int byteSize = sizeof(DefaultSegmentationDataType);
   for (unsigned int dim = 0; dim < segmentation->GetDimension(); ++dim)
   {
     byteSize *= segmentation->GetDimension(dim);
   }
   memset( segmentation->GetData(), 0, byteSize );

   if (original->GetTimeSlicedGeometry() )
   {
     AffineGeometryFrame3D::Pointer originalGeometryAGF =
        original->GetTimeSlicedGeometry()->Clone();
     TimeSlicedGeometry::Pointer originalGeometry =
        dynamic_cast<TimeSlicedGeometry*>(
          originalGeometryAGF.GetPointer() );
     segmentation->SetGeometry( originalGeometry );
   }

   return segmentation;
}

Regards,
Daniel


-- 
Dr. Daniel Maleike                         Phone: +49 6221 42 2326
Deutsches Krebsforschungszentrum           Im Neuenheimer Feld 280
Medical and Biological Informatics (E130)         69120 Heidelberg

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to