Example #1
0
mitk::ImageDataItem::ImageDataItem(const mitk::ImageDescriptor::Pointer desc, void *data, bool manageMemory)
  : m_Data((unsigned char*)data), m_ManageMemory(manageMemory), m_VtkImageData(NULL), m_Offset(0), m_IsComplete(false), m_Size(0)
{
  m_PixelType = new mitk::PixelType(desc->GetChannelDescriptor(0).GetPixelType());

  // compute size
  const unsigned int *dimensions = desc->GetDimensions();

  m_Dimension = desc->GetNumberOfDimensions();
  for( unsigned int i=0; i<m_Dimension; i++)
    m_Dimensions[i] = dimensions[i];

  this->ComputeItemSize(m_Dimensions, m_Dimension );

  if(m_Data == NULL)
  {
    m_Data = mitk::MemoryUtilities::AllocateElements<unsigned char>( m_Size );
    m_ManageMemory = true;
  }

  m_ReferenceCountLock.Lock();
  m_ReferenceCount = 0;
  m_ReferenceCountLock.Unlock();

}
Example #2
0
mitk::ImageDataItem::ImageDataItem(const ImageDataItem& aParent, const mitk::ImageDescriptor::Pointer desc, unsigned int dimension, void *data, bool manageMemory, size_t offset) :
  m_Data(NULL), m_ManageMemory(false), m_VtkImageData(NULL), m_Offset(offset), m_IsComplete(false), m_Size(0),
  m_Parent(&aParent)
{
  m_PixelType = new mitk::PixelType(aParent.GetPixelType());
  m_Data = static_cast<unsigned char*>(aParent.GetData())+offset;

  // compute size
  const unsigned int *dims = desc->GetDimensions();
  m_Dimension = dimension;
  for( unsigned int i=0; i<dimension; i++)
    m_Dimensions[i] = desc->GetDimensions()[i];
  this->ComputeItemSize(m_Dimensions,dimension);

  if(data != NULL)
  {
    memcpy(m_Data, data, m_Size);
    if(manageMemory)
    {
      delete [] (unsigned char*) data;
    }
  }
  m_ReferenceCountLock.Lock();
  m_ReferenceCount = 0;
  m_ReferenceCountLock.Unlock();
}
Example #3
0
static mitkIpPicDescriptor * CastToIpPicDescriptor(mitk::Image::Pointer refImg,
  mitk::ImageWriteAccessor *imageAccess,
  mitkIpPicDescriptor *picDesc)
{
  const mitk::ImageDescriptor::Pointer imDesc = refImg->GetImageDescriptor();

  // initialize dimension information
  for (unsigned int i = 0; i < 8; i++)
  {
    picDesc->n[i] = 1;
  }

  // set dimension information
  picDesc->dim = refImg->GetDimension();
  memcpy(picDesc->n, imDesc->GetDimensions(), picDesc->dim * sizeof(unsigned int));

  picDesc->type = ::CastToIpPicType(refImg->GetPixelType().GetComponentType());
  picDesc->bpe = refImg->GetPixelType().GetBpe();
  if (imageAccess != nullptr)
  {
    picDesc->data = imageAccess->GetData();
  }

  return picDesc;
}
Example #4
0
void mitk::Image::Initialize(const mitk::ImageDescriptor::Pointer inDesc)
{
  // store the descriptor
  this->m_ImageDescriptor = inDesc;

  // initialize image
  this->Initialize( inDesc->GetChannelDescriptor(0).GetPixelType(), inDesc->GetNumberOfDimensions(), inDesc->GetDimensions(), 1 );
}
Example #5
0
mitkIpPicDescriptor* mitk::CastToIpPicDescriptor(mitk::Image::Pointer refImg, mitkIpPicDescriptor* picDesc)
{
  const mitk::ImageDescriptor::Pointer imDesc = refImg->GetImageDescriptor();

  // initialize dimension information
  for (unsigned int i=0; i<8; i++)
  {
      picDesc->n[i] = 1;
  }

  // set dimension information
  picDesc->dim = refImg->GetDimension();
  memcpy( picDesc->n, imDesc->GetDimensions(), picDesc->dim * sizeof(unsigned int) );

  picDesc->type = CastToIpPicType( refImg->GetPixelType().GetTypeId() );
  picDesc->bpe = refImg->GetPixelType().GetBpe();
  picDesc->data = refImg->GetData();

  return picDesc;
}