本文整理汇总了C++中proportionaltimegeometry::Pointer::Initialize方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::Initialize方法的具体用法?C++ Pointer::Initialize怎么用?C++ Pointer::Initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类proportionaltimegeometry::Pointer
的用法示例。
在下文中一共展示了Pointer::Initialize方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
void mitk::SlicedData::SetGeometry(BaseGeometry *aGeometry3D)
{
if (aGeometry3D != nullptr)
{
ProportionalTimeGeometry::Pointer timeGeometry = ProportionalTimeGeometry::New();
SlicedGeometry3D::Pointer slicedGeometry = dynamic_cast<SlicedGeometry3D *>(aGeometry3D);
if (slicedGeometry.IsNull())
{
PlaneGeometry *geometry2d = dynamic_cast<PlaneGeometry *>(aGeometry3D);
if (geometry2d != nullptr && dynamic_cast<mitk::AbstractTransformGeometry *>(aGeometry3D) == nullptr)
{
if ((GetSlicedGeometry()->GetPlaneGeometry(0) == geometry2d) && (GetSlicedGeometry()->GetSlices() == 1))
return;
slicedGeometry = SlicedGeometry3D::New();
slicedGeometry->InitializeEvenlySpaced(geometry2d, 1);
}
else
{
slicedGeometry = SlicedGeometry3D::New();
PlaneGeometry::Pointer planeGeometry = PlaneGeometry::New();
planeGeometry->InitializeStandardPlane(aGeometry3D);
slicedGeometry->InitializeEvenlySpaced(planeGeometry, (unsigned int)(aGeometry3D->GetExtent(2)));
}
}
assert(slicedGeometry.IsNotNull());
timeGeometry->Initialize(slicedGeometry, 1);
Superclass::SetTimeGeometry(timeGeometry);
}
else
{
if (GetGeometry() == nullptr)
return;
Superclass::SetGeometry(nullptr);
}
}
示例2: switch
void mitk::Image::Initialize(vtkImageData* vtkimagedata, int channels, int tDim, int sDim, int pDim)
{
if(vtkimagedata==NULL) return;
m_Dimension=vtkimagedata->GetDataDimension();
unsigned int i, *tmpDimensions=new unsigned int[m_Dimension>4?m_Dimension:4];
for(i=0;i<m_Dimension;++i) tmpDimensions[i]=vtkimagedata->GetDimensions()[i];
if(m_Dimension<4)
{
unsigned int *p;
for(i=0,p=tmpDimensions+m_Dimension;i<4-m_Dimension;++i, ++p)
*p=1;
}
if(pDim>=0)
{
tmpDimensions[1]=pDim;
if(m_Dimension < 2)
m_Dimension = 2;
}
if(sDim>=0)
{
tmpDimensions[2]=sDim;
if(m_Dimension < 3)
m_Dimension = 3;
}
if(tDim>=0)
{
tmpDimensions[3]=tDim;
if(m_Dimension < 4)
m_Dimension = 4;
}
switch ( vtkimagedata->GetScalarType() )
{
case VTK_BIT:
case VTK_CHAR:
//pixelType.Initialize(typeid(char), vtkimagedata->GetNumberOfScalarComponents());
Initialize(mitk::MakeScalarPixelType<char>(), m_Dimension, tmpDimensions, channels);
break;
case VTK_UNSIGNED_CHAR:
//pixelType.Initialize(typeid(unsigned char), vtkimagedata->GetNumberOfScalarComponents());
Initialize(mitk::MakeScalarPixelType<unsigned char>(), m_Dimension, tmpDimensions, channels);
break;
case VTK_SHORT:
//pixelType.Initialize(typeid(short), vtkimagedata->GetNumberOfScalarComponents());
Initialize(mitk::MakeScalarPixelType<short>(), m_Dimension, tmpDimensions, channels);
break;
case VTK_UNSIGNED_SHORT:
//pixelType.Initialize(typeid(unsigned short), vtkimagedata->GetNumberOfScalarComponents());
Initialize(mitk::MakeScalarPixelType<unsigned short>(), m_Dimension, tmpDimensions, channels);
break;
case VTK_INT:
//pixelType.Initialize(typeid(int), vtkimagedata->GetNumberOfScalarComponents());
Initialize(mitk::MakeScalarPixelType<int>(), m_Dimension, tmpDimensions, channels);
break;
case VTK_UNSIGNED_INT:
//pixelType.Initialize(typeid(unsigned int), vtkimagedata->GetNumberOfScalarComponents());
Initialize(mitk::MakeScalarPixelType<unsigned int>(), m_Dimension, tmpDimensions, channels);
break;
case VTK_LONG:
//pixelType.Initialize(typeid(long), vtkimagedata->GetNumberOfScalarComponents());
Initialize(mitk::MakeScalarPixelType<long>(), m_Dimension, tmpDimensions, channels);
break;
case VTK_UNSIGNED_LONG:
//pixelType.Initialize(typeid(unsigned long), vtkimagedata->GetNumberOfScalarComponents());
Initialize(mitk::MakeScalarPixelType<unsigned long>(), m_Dimension, tmpDimensions, channels);
break;
case VTK_FLOAT:
//pixelType.Initialize(typeid(float), vtkimagedata->GetNumberOfScalarComponents());
Initialize(mitk::MakeScalarPixelType<float>(), m_Dimension, tmpDimensions, channels);
break;
case VTK_DOUBLE:
//pixelType.Initialize(typeid(double), vtkimagedata->GetNumberOfScalarComponents());
Initialize(mitk::MakeScalarPixelType<double>(), m_Dimension, tmpDimensions, channels);
break;
default:
break;
}
/*
Initialize(pixelType,
m_Dimension,
tmpDimensions,
channels);
*/
const double *spacinglist = vtkimagedata->GetSpacing();
Vector3D spacing;
FillVector3D(spacing, spacinglist[0], 1.0, 1.0);
if(m_Dimension>=2)
spacing[1]=spacinglist[1];
if(m_Dimension>=3)
spacing[2]=spacinglist[2];
// access origin of vtkImage
Point3D origin;
double vtkorigin[3];
vtkimagedata->GetOrigin(vtkorigin);
FillVector3D(origin, vtkorigin[0], 0.0, 0.0);
//.........这里部分代码省略.........
示例3: Clear
void mitk::Image::Initialize(const mitk::PixelType& type, unsigned int dimension, const unsigned int *dimensions, unsigned int channels)
{
Clear();
m_Dimension=dimension;
if(!dimensions)
itkExceptionMacro(<< "invalid zero dimension image");
unsigned int i;
for(i=0;i<dimension;++i)
{
if(dimensions[i]<1)
itkExceptionMacro(<< "invalid dimension[" << i << "]: " << dimensions[i]);
}
// create new array since the old was deleted
m_Dimensions = new unsigned int[MAX_IMAGE_DIMENSIONS];
// initialize the first four dimensions to 1, the remaining 4 to 0
FILL_C_ARRAY(m_Dimensions, 4, 1u);
FILL_C_ARRAY((m_Dimensions+4), 4, 0u);
// copy in the passed dimension information
std::memcpy(m_Dimensions, dimensions, sizeof(unsigned int)*m_Dimension);
this->m_ImageDescriptor = mitk::ImageDescriptor::New();
this->m_ImageDescriptor->Initialize( this->m_Dimensions, this->m_Dimension );
for(i=0;i<4;++i)
{
m_LargestPossibleRegion.SetIndex(i, 0);
m_LargestPossibleRegion.SetSize (i, m_Dimensions[i]);
}
m_LargestPossibleRegion.SetIndex(i, 0);
m_LargestPossibleRegion.SetSize(i, channels);
if(m_LargestPossibleRegion.GetNumberOfPixels()==0)
{
delete [] m_Dimensions;
m_Dimensions = NULL;
return;
}
for( unsigned int i=0u; i<channels; i++)
{
this->m_ImageDescriptor->AddNewChannel( type );
}
PlaneGeometry::Pointer planegeometry = PlaneGeometry::New();
planegeometry->InitializeStandardPlane(m_Dimensions[0], m_Dimensions[1]);
SlicedGeometry3D::Pointer slicedGeometry = SlicedGeometry3D::New();
slicedGeometry->InitializeEvenlySpaced(planegeometry, m_Dimensions[2]);
if(dimension>=4)
{
TimeBounds timebounds;
timebounds[0] = 0.0;
timebounds[1] = 1.0;
slicedGeometry->SetTimeBounds(timebounds);
}
ProportionalTimeGeometry::Pointer timeGeometry = ProportionalTimeGeometry::New();
timeGeometry->Initialize(slicedGeometry, m_Dimensions[3]);
for (TimeStepType step = 0; step < timeGeometry->CountTimeSteps(); ++step)
{
timeGeometry->GetGeometryForTimeStep(step)->ImageGeometryOn();
}
SetTimeGeometry(timeGeometry);
ImageDataItemPointer dnull=NULL;
m_Channels.assign(GetNumberOfChannels(), dnull);
m_Volumes.assign(GetNumberOfChannels()*m_Dimensions[3], dnull);
m_Slices.assign(GetNumberOfChannels()*m_Dimensions[3]*m_Dimensions[2], dnull);
ComputeOffsetTable();
Initialize();
m_Initialized = true;
}
示例4: localeSwitch
std::vector<BaseData::Pointer> ItkImageIO::Read()
{
std::vector<BaseData::Pointer> result;
mitk::LocaleSwitch localeSwitch("C");
Image::Pointer image = Image::New();
const unsigned int MINDIM = 2;
const unsigned int MAXDIM = 4;
const std::string path = this->GetLocalFileName();
MITK_INFO << "loading " << path << " via itk::ImageIOFactory... " << std::endl;
// Check to see if we can read the file given the name or prefix
if (path.empty())
{
mitkThrow() << "Empty filename in mitk::ItkImageIO ";
}
// Got to allocate space for the image. Determine the characteristics of
// the image.
m_ImageIO->SetFileName(path);
m_ImageIO->ReadImageInformation();
unsigned int ndim = m_ImageIO->GetNumberOfDimensions();
if (ndim < MINDIM || ndim > MAXDIM)
{
MITK_WARN << "Sorry, only dimensions 2, 3 and 4 are supported. The given file has " << ndim
<< " dimensions! Reading as 4D.";
ndim = MAXDIM;
}
itk::ImageIORegion ioRegion(ndim);
itk::ImageIORegion::SizeType ioSize = ioRegion.GetSize();
itk::ImageIORegion::IndexType ioStart = ioRegion.GetIndex();
unsigned int dimensions[MAXDIM];
dimensions[0] = 0;
dimensions[1] = 0;
dimensions[2] = 0;
dimensions[3] = 0;
ScalarType spacing[MAXDIM];
spacing[0] = 1.0f;
spacing[1] = 1.0f;
spacing[2] = 1.0f;
spacing[3] = 1.0f;
Point3D origin;
origin.Fill(0);
unsigned int i;
for (i = 0; i < ndim; ++i)
{
ioStart[i] = 0;
ioSize[i] = m_ImageIO->GetDimensions(i);
if (i < MAXDIM)
{
dimensions[i] = m_ImageIO->GetDimensions(i);
spacing[i] = m_ImageIO->GetSpacing(i);
if (spacing[i] <= 0)
spacing[i] = 1.0f;
}
if (i < 3)
{
origin[i] = m_ImageIO->GetOrigin(i);
}
}
ioRegion.SetSize(ioSize);
ioRegion.SetIndex(ioStart);
MITK_INFO << "ioRegion: " << ioRegion << std::endl;
m_ImageIO->SetIORegion(ioRegion);
void *buffer = new unsigned char[m_ImageIO->GetImageSizeInBytes()];
m_ImageIO->Read(buffer);
image->Initialize(MakePixelType(m_ImageIO), ndim, dimensions);
image->SetImportChannel(buffer, 0, Image::ManageMemory);
const itk::MetaDataDictionary &dictionary = m_ImageIO->GetMetaDataDictionary();
// access direction of itk::Image and include spacing
mitk::Matrix3D matrix;
matrix.SetIdentity();
unsigned int j, itkDimMax3 = (ndim >= 3 ? 3 : ndim);
for (i = 0; i < itkDimMax3; ++i)
for (j = 0; j < itkDimMax3; ++j)
matrix[i][j] = m_ImageIO->GetDirection(j)[i];
// re-initialize PlaneGeometry with origin and direction
PlaneGeometry *planeGeometry = image->GetSlicedGeometry(0)->GetPlaneGeometry(0);
planeGeometry->SetOrigin(origin);
planeGeometry->GetIndexToWorldTransform()->SetMatrix(matrix);
// re-initialize SlicedGeometry3D
SlicedGeometry3D *slicedGeometry = image->GetSlicedGeometry(0);
slicedGeometry->InitializeEvenlySpaced(planeGeometry, image->GetDimension(2));
slicedGeometry->SetSpacing(spacing);
//.........这里部分代码省略.........
示例5: ioRegion
std::vector<BaseData::Pointer> LabelSetImageIO::Read()
{
const std::string& locale = "C";
const std::string& currLocale = setlocale( LC_ALL, NULL );
if ( locale.compare(currLocale)!=0 )
{
try
{
setlocale(LC_ALL, locale.c_str());
}
catch(...)
{
mitkThrow() << "Could not set locale.";
}
}
// begin regular image loading, adapted from mitkItkImageIO
itk::NrrdImageIO::Pointer nrrdImageIO = itk::NrrdImageIO::New();
Image::Pointer image = Image::New();
const unsigned int MINDIM = 2;
const unsigned int MAXDIM = 4;
const std::string path = this->GetLocalFileName();
MITK_INFO << "loading " << path << " via itk::ImageIOFactory... " << std::endl;
// Check to see if we can read the file given the name or prefix
if (path.empty())
{
mitkThrow() << "Empty filename in mitk::ItkImageIO ";
}
// Got to allocate space for the image. Determine the characteristics of
// the image.
nrrdImageIO->SetFileName(path);
nrrdImageIO->ReadImageInformation();
unsigned int ndim = nrrdImageIO->GetNumberOfDimensions();
if (ndim < MINDIM || ndim > MAXDIM)
{
MITK_WARN << "Sorry, only dimensions 2, 3 and 4 are supported. The given file has " << ndim << " dimensions! Reading as 4D.";
ndim = MAXDIM;
}
itk::ImageIORegion ioRegion(ndim);
itk::ImageIORegion::SizeType ioSize = ioRegion.GetSize();
itk::ImageIORegion::IndexType ioStart = ioRegion.GetIndex();
unsigned int dimensions[MAXDIM];
dimensions[0] = 0;
dimensions[1] = 0;
dimensions[2] = 0;
dimensions[3] = 0;
ScalarType spacing[MAXDIM];
spacing[0] = 1.0f;
spacing[1] = 1.0f;
spacing[2] = 1.0f;
spacing[3] = 1.0f;
Point3D origin;
origin.Fill(0);
unsigned int i;
for (i = 0; i < ndim; ++i)
{
ioStart[i] = 0;
ioSize[i] = nrrdImageIO->GetDimensions(i);
if (i<MAXDIM)
{
dimensions[i] = nrrdImageIO->GetDimensions(i);
spacing[i] = nrrdImageIO->GetSpacing(i);
if (spacing[i] <= 0)
spacing[i] = 1.0f;
}
if (i<3)
{
origin[i] = nrrdImageIO->GetOrigin(i);
}
}
ioRegion.SetSize(ioSize);
ioRegion.SetIndex(ioStart);
MITK_INFO << "ioRegion: " << ioRegion << std::endl;
nrrdImageIO->SetIORegion(ioRegion);
void* buffer = new unsigned char[nrrdImageIO->GetImageSizeInBytes()];
nrrdImageIO->Read(buffer);
image->Initialize(MakePixelType(nrrdImageIO), ndim, dimensions);
image->SetImportChannel(buffer, 0, Image::ManageMemory);
// access direction of itk::Image and include spacing
mitk::Matrix3D matrix;
matrix.SetIdentity();
unsigned int j, itkDimMax3 = (ndim >= 3 ? 3 : ndim);
for (i = 0; i < itkDimMax3; ++i)
for (j = 0; j < itkDimMax3; ++j)
//.........这里部分代码省略.........
示例6: pixelType
void mitk::Image::Initialize(vtkImageData* vtkimagedata, int channels, int tDim, int sDim, int pDim)
{
if(vtkimagedata==nullptr) return;
m_Dimension=vtkimagedata->GetDataDimension();
unsigned int i, *tmpDimensions=new unsigned int[m_Dimension>4?m_Dimension:4];
for(i=0;i<m_Dimension;++i) tmpDimensions[i]=vtkimagedata->GetDimensions()[i];
if(m_Dimension<4)
{
unsigned int *p;
for(i=0,p=tmpDimensions+m_Dimension;i<4-m_Dimension;++i, ++p)
*p=1;
}
if(pDim>=0)
{
tmpDimensions[1]=pDim;
if(m_Dimension < 2)
m_Dimension = 2;
}
if(sDim>=0)
{
tmpDimensions[2]=sDim;
if(m_Dimension < 3)
m_Dimension = 3;
}
if(tDim>=0)
{
tmpDimensions[3]=tDim;
if(m_Dimension < 4)
m_Dimension = 4;
}
mitk::PixelType pixelType(MakePixelType(vtkimagedata));
Initialize(pixelType, m_Dimension, tmpDimensions, channels);
const double *spacinglist = vtkimagedata->GetSpacing();
Vector3D spacing;
FillVector3D(spacing, spacinglist[0], 1.0, 1.0);
if(m_Dimension>=2)
spacing[1]=spacinglist[1];
if(m_Dimension>=3)
spacing[2]=spacinglist[2];
// access origin of vtkImage
Point3D origin;
double vtkorigin[3];
vtkimagedata->GetOrigin(vtkorigin);
FillVector3D(origin, vtkorigin[0], 0.0, 0.0);
if(m_Dimension>=2)
origin[1]=vtkorigin[1];
if(m_Dimension>=3)
origin[2]=vtkorigin[2];
SlicedGeometry3D* slicedGeometry = GetSlicedGeometry(0);
// re-initialize PlaneGeometry with origin and direction
PlaneGeometry* planeGeometry = static_cast<PlaneGeometry*>(slicedGeometry->GetPlaneGeometry(0));
planeGeometry->SetOrigin(origin);
// re-initialize SlicedGeometry3D
slicedGeometry->SetOrigin(origin);
slicedGeometry->SetSpacing(spacing);
ProportionalTimeGeometry::Pointer timeGeometry = ProportionalTimeGeometry::New();
timeGeometry->Initialize(slicedGeometry, m_Dimensions[3]);
SetTimeGeometry(timeGeometry);
delete [] tmpDimensions;
}
示例7: itkWarningMacro
void mitk::ExtrudedContour::BuildGeometry()
{
if(m_Contour.IsNull())
return;
// Initialize(1);
Vector3D nullvector; nullvector.Fill(0.0);
float xProj[3];
unsigned int i;
unsigned int numPts = 20; //m_Contour->GetNumberOfPoints();
mitk::Contour::PathPointer path = m_Contour->GetContourPath();
mitk::Contour::PathType::InputType cstart = path->StartOfInput();
mitk::Contour::PathType::InputType cend = path->EndOfInput();
mitk::Contour::PathType::InputType cstep = (cend-cstart)/numPts;
mitk::Contour::PathType::InputType ccur;
// Part I: guarantee/calculate legal vectors
m_Vector.Normalize();
itk2vtk(m_Vector, m_Normal);
// check m_Vector
if(mitk::Equal(m_Vector, nullvector) || m_AutomaticVectorGeneration)
{
if ( m_AutomaticVectorGeneration == false)
itkWarningMacro("Extrusion vector is 0 ("<< m_Vector << "); trying to use normal of polygon");
vtkPoints *loopPoints = vtkPoints::New();
//mitk::Contour::PointsContainerIterator pointsIt = m_Contour->GetPoints()->Begin();
double vtkpoint[3];
unsigned int i=0;
for(i=0, ccur=cstart; i<numPts; ++i, ccur+=cstep)
{
itk2vtk(path->Evaluate(ccur), vtkpoint);
loopPoints->InsertNextPoint(vtkpoint);
}
// Make sure points define a loop with a m_Normal
vtkPolygon::ComputeNormal(loopPoints, m_Normal);
loopPoints->Delete();
vtk2itk(m_Normal, m_Vector);
if(mitk::Equal(m_Vector, nullvector))
{
itkExceptionMacro("Cannot calculate normal of polygon");
}
}
// check m_RightVector
if((mitk::Equal(m_RightVector, nullvector)) || (mitk::Equal(m_RightVector*m_Vector, 0.0)==false))
{
if(mitk::Equal(m_RightVector, nullvector))
{
itkDebugMacro("Right vector is 0. Calculating.");
}
else
{
itkWarningMacro("Right vector ("<<m_RightVector<<") not perpendicular to extrusion vector "<<m_Vector<<": "<<m_RightVector*m_Vector);
}
// calculate a legal m_RightVector
if( mitk::Equal( m_Vector[1], 0.0f ) == false )
{
FillVector3D( m_RightVector, 1.0f, -m_Vector[0]/m_Vector[1], 0.0f );
m_RightVector.Normalize();
}
else
{
FillVector3D( m_RightVector, 0.0f, 1.0f, 0.0f );
}
}
// calculate down-vector
VnlVector rightDV = m_RightVector.GetVnlVector(); rightDV.normalize(); vnl2vtk(rightDV, m_Right);
VnlVector downDV = vnl_cross_3d( m_Vector.GetVnlVector(), rightDV ); downDV.normalize(); vnl2vtk(downDV, m_Down);
// Part II: calculate plane as base for extrusion, project the contour
// on this plane and store as polygon for IsInside test and BoundingBox calculation
// initialize m_ProjectionPlane, yet with origin at 0
m_ProjectionPlane->InitializeStandardPlane(rightDV, downDV);
// create vtkPolygon from contour and simultaneously determine 2D bounds of
// contour projected on m_ProjectionPlane
//mitk::Contour::PointsContainerIterator pointsIt = m_Contour->GetPoints()->Begin();
m_Polygon->Points->Reset();
m_Polygon->Points->SetNumberOfPoints(numPts);
m_Polygon->PointIds->Reset();
m_Polygon->PointIds->SetNumberOfIds(numPts);
mitk::Point2D pt2d;
mitk::Point3D pt3d;
mitk::Point2D min, max;
min.Fill(ScalarTypeNumericTraits::max());
max.Fill(ScalarTypeNumericTraits::min());
xProj[2]=0.0;
for(i=0, ccur=cstart; i<numPts; ++i, ccur+=cstep)
{
pt3d.CastFrom(path->Evaluate(ccur));
m_ProjectionPlane->Map(pt3d, pt2d);
xProj[0]=pt2d[0];
if(pt2d[0]<min[0]) min[0]=pt2d[0];
//.........这里部分代码省略.........
示例8: InitializeView
bool RenderingManager::InitializeView(vtkRenderWindow * renderWindow, const BaseGeometry * geometry, bool initializeGlobalTimeSNC)
{
ProportionalTimeGeometry::Pointer propTimeGeometry = ProportionalTimeGeometry::New();
propTimeGeometry->Initialize(dynamic_cast<BaseGeometry *>(geometry->Clone().GetPointer()), 1);
return InitializeView(renderWindow, propTimeGeometry, initializeGlobalTimeSNC);
}
示例9: mitkIpPicGetHeader
mitk::Image::Pointer mitk::PicFileReader::CreateImage()
{
Image::Pointer output = Image::New();
std::string fileName = this->GetLocalFileName();
mitkIpPicDescriptor *header = mitkIpPicGetHeader(const_cast<char *>(fileName.c_str()), NULL);
if (!header)
{
mitkThrow() << "File could not be read.";
}
header = mitkIpPicGetTags(const_cast<char *>(fileName.c_str()), header);
int channels = 1;
mitkIpPicTSV_t *tsv;
if ((tsv = mitkIpPicQueryTag(header, "SOURCE HEADER")) != NULL)
{
if (tsv->n[0] > 1e+06)
{
mitkIpPicTSV_t *tsvSH;
tsvSH = mitkIpPicDelTag(header, "SOURCE HEADER");
mitkIpPicFreeTag(tsvSH);
}
}
if ((tsv = mitkIpPicQueryTag(header, "ICON80x80")) != NULL)
{
mitkIpPicTSV_t *tsvSH;
tsvSH = mitkIpPicDelTag(header, "ICON80x80");
mitkIpPicFreeTag(tsvSH);
}
if ((tsv = mitkIpPicQueryTag(header, "VELOCITY")) != NULL)
{
++channels;
mitkIpPicDelTag(header, "VELOCITY");
}
if (header == NULL || header->bpe == 0)
{
mitkThrow() << " Could not read file " << fileName;
}
// if pic image only 2D, the n[2] value is not initialized
unsigned int slices = 1;
if (header->dim == 2)
{
header->n[2] = slices;
}
// First initialize the geometry of the output image by the pic-header
SlicedGeometry3D::Pointer slicedGeometry = mitk::SlicedGeometry3D::New();
PicHelper::InitializeEvenlySpaced(header, header->n[2], slicedGeometry);
// if pic image only 3D, the n[3] value is not initialized
unsigned int timesteps = 1;
if (header->dim > 3)
{
timesteps = header->n[3];
}
slicedGeometry->ImageGeometryOn();
ProportionalTimeGeometry::Pointer timeGeometry = ProportionalTimeGeometry::New();
timeGeometry->Initialize(slicedGeometry, timesteps);
// Cast the pic descriptor to ImageDescriptor and initialize the output
output->Initialize(CastToImageDescriptor(header));
output->SetTimeGeometry(timeGeometry);
mitkIpPicFree(header);
return output;
}
示例10: ioRegion
std::vector<BaseData::Pointer> ItkImageIO::Read()
{
std::vector<BaseData::Pointer> result;
const std::string& locale = "C";
const std::string& currLocale = setlocale( LC_ALL, NULL );
if ( locale.compare(currLocale)!=0 )
{
try
{
setlocale(LC_ALL, locale.c_str());
}
catch(...)
{
MITK_INFO << "Could not set locale " << locale;
}
}
Image::Pointer image = Image::New();
const unsigned int MINDIM = 2;
const unsigned int MAXDIM = 4;
const std::string path = this->GetLocalFileName();
MITK_INFO << "loading " << path << " via itk::ImageIOFactory... " << std::endl;
// Check to see if we can read the file given the name or prefix
if (path.empty())
{
mitkThrow() << "Empty filename in mitk::ItkImageIO ";
}
// Got to allocate space for the image. Determine the characteristics of
// the image.
m_ImageIO->SetFileName( path );
m_ImageIO->ReadImageInformation();
unsigned int ndim = m_ImageIO->GetNumberOfDimensions();
if ( ndim < MINDIM || ndim > MAXDIM )
{
MITK_WARN << "Sorry, only dimensions 2, 3 and 4 are supported. The given file has " << ndim << " dimensions! Reading as 4D.";
ndim = MAXDIM;
}
itk::ImageIORegion ioRegion( ndim );
itk::ImageIORegion::SizeType ioSize = ioRegion.GetSize();
itk::ImageIORegion::IndexType ioStart = ioRegion.GetIndex();
unsigned int dimensions[ MAXDIM ];
dimensions[ 0 ] = 0;
dimensions[ 1 ] = 0;
dimensions[ 2 ] = 0;
dimensions[ 3 ] = 0;
ScalarType spacing[ MAXDIM ];
spacing[ 0 ] = 1.0f;
spacing[ 1 ] = 1.0f;
spacing[ 2 ] = 1.0f;
spacing[ 3 ] = 1.0f;
Point3D origin;
origin.Fill(0);
unsigned int i;
for ( i = 0; i < ndim ; ++i )
{
ioStart[ i ] = 0;
ioSize[ i ] = m_ImageIO->GetDimensions( i );
if(i<MAXDIM)
{
dimensions[ i ] = m_ImageIO->GetDimensions( i );
spacing[ i ] = m_ImageIO->GetSpacing( i );
if(spacing[ i ] <= 0)
spacing[ i ] = 1.0f;
}
if(i<3)
{
origin[ i ] = m_ImageIO->GetOrigin( i );
}
}
ioRegion.SetSize( ioSize );
ioRegion.SetIndex( ioStart );
MITK_INFO << "ioRegion: " << ioRegion << std::endl;
m_ImageIO->SetIORegion( ioRegion );
void* buffer = new unsigned char[m_ImageIO->GetImageSizeInBytes()];
m_ImageIO->Read( buffer );
image->Initialize( MakePixelType(m_ImageIO), ndim, dimensions );
image->SetImportChannel( buffer, 0, Image::ManageMemory );
// access direction of itk::Image and include spacing
mitk::Matrix3D matrix;
matrix.SetIdentity();
unsigned int j, itkDimMax3 = (ndim >= 3? 3 : ndim);
for ( i=0; i < itkDimMax3; ++i)
for( j=0; j < itkDimMax3; ++j )
//.........这里部分代码省略.........