本文整理汇总了C++中image::Pointer::GetDimensions方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::GetDimensions方法的具体用法?C++ Pointer::GetDimensions怎么用?C++ Pointer::GetDimensions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类image::Pointer
的用法示例。
在下文中一共展示了Pointer::GetDimensions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ImageFileReaderException
void mitk::PicFileReader::GenerateData()
{
Image::Pointer output = this->GetOutput();
// Check to see if we can read the file given the name or prefix
//
if ( m_FileName == "" && m_FilePrefix == "" )
{
throw itk::ImageFileReaderException(__FILE__, __LINE__, "One of FileName or FilePrefix must be non-empty");
}
if( m_FileName != "")
{
mitkIpPicDescriptor* outputPic = mitkIpPicNew();
outputPic = CastToIpPicDescriptor(output, outputPic);
mitkIpPicDescriptor* pic=MITKipPicGet(const_cast<char *>(m_FileName.c_str()),
outputPic);
// comes upside-down (in MITK coordinates) from PIC file
ConvertHandedness(pic);
mitkIpPicTSV_t *tsv;
if ( (tsv = mitkIpPicQueryTag( pic, "SOURCE HEADER" )) != NULL)
{
if(tsv->n[0]>1e+06)
{
mitkIpPicTSV_t *tsvSH;
tsvSH = mitkIpPicDelTag( pic, "SOURCE HEADER" );
mitkIpPicFreeTag(tsvSH);
}
}
if ( (tsv = mitkIpPicQueryTag( pic, "ICON80x80" )) != NULL)
{
mitkIpPicTSV_t *tsvSH;
tsvSH = mitkIpPicDelTag( pic, "ICON80x80" );
mitkIpPicFreeTag(tsvSH);
}
if ( (tsv = mitkIpPicQueryTag( pic, "VELOCITY" )) != NULL)
{
mitkIpPicDescriptor* header = mitkIpPicCopyHeader(pic, NULL);
header->data = tsv->value;
ConvertHandedness(header);
output->SetChannel(header->data, 1);
header->data = NULL;
mitkIpPicFree(header);
mitkIpPicDelTag( pic, "VELOCITY" );
}
//slice-wise reading
//currently much too slow.
//else
//{
// int sstart, smax;
// int tstart, tmax;
// sstart=output->GetRequestedRegion().GetIndex(2);
// smax=sstart+output->GetRequestedRegion().GetSize(2);
// tstart=output->GetRequestedRegion().GetIndex(3);
// tmax=tstart+output->GetRequestedRegion().GetSize(3);
// int s,t;
// for(s=sstart; s<smax; ++s)
// {
// for(t=tstart; t<tmax; ++t)
// {
// mitkIpPicDescriptor* pic=mitkIpPicGetSlice(const_cast<char *>(m_FileName.c_str()), NULL, t*smax+s+1);
// output->SetPicSlice(pic,s,t);
// }
// }
//}
}
else
{
int position;
mitkIpPicDescriptor* pic=NULL;
int zDim=(output->GetDimension()>2?output->GetDimensions()[2]:1);
printf("\n zdim is %u \n",zDim);
for (position = 0; position < zDim; ++position)
{
char fullName[1024];
sprintf(fullName, m_FilePattern.c_str(), m_FilePrefix.c_str(), m_StartFileIndex+position);
pic=MITKipPicGet(fullName, pic);
if(pic==NULL)
{
itkDebugMacro("Pic file '" << fullName << "' does not exist.");
}
/* FIXME else
if(output->SetPicSlice(pic, position)==false)
{
itkDebugMacro("Image '" << fullName << "' could not be added to Image.");
}*/
}
if(pic!=NULL)
mitkIpPicFree(pic);
}
}
示例2: FeatureDescriptionPrefix
mitk::GIFVolumetricStatistics::FeatureListType mitk::GIFVolumetricStatistics::CalculateFeatures(const Image::Pointer & image, const Image::Pointer &mask)
{
FeatureListType featureList;
if (image->GetDimension() < 3)
{
return featureList;
}
AccessByItk_3(image, CalculateVolumeStatistic, mask, featureList, FeatureDescriptionPrefix());
AccessByItk_3(mask, CalculateLargestDiameter, image, featureList, FeatureDescriptionPrefix());
vtkSmartPointer<vtkImageMarchingCubes> mesher = vtkSmartPointer<vtkImageMarchingCubes>::New();
vtkSmartPointer<vtkMassProperties> stats = vtkSmartPointer<vtkMassProperties>::New();
mesher->SetInputData(mask->GetVtkImageData());
mesher->SetValue(0, 0.5);
stats->SetInputConnection(mesher->GetOutputPort());
stats->Update();
double pi = vnl_math::pi;
double meshVolume = stats->GetVolume();
double meshSurf = stats->GetSurfaceArea();
double pixelVolume = featureList[1].second;
double pixelSurface = featureList[3].second;
MITK_INFO << "Surface: " << pixelSurface << " Volume: " << pixelVolume;
double compactness1 = pixelVolume / (std::sqrt(pi) * std::pow(meshSurf, 2.0 / 3.0));
double compactness1Pixel = pixelVolume / (std::sqrt(pi) * std::pow(pixelSurface, 2.0 / 3.0));
//This is the definition used by Aertz. However, due to 2/3 this feature is not demensionless. Use compactness3 instead.
double compactness2 = 36 * pi*pixelVolume*pixelVolume / meshSurf / meshSurf / meshSurf;
double compactness2MeshMesh = 36 * pi*meshVolume*meshVolume / meshSurf / meshSurf / meshSurf;
double compactness2Pixel = 36 * pi*pixelVolume*pixelVolume / pixelSurface / pixelSurface / pixelSurface;
double compactness3 = pixelVolume / (std::sqrt(pi) * std::pow(meshSurf, 3.0 / 2.0));
double compactness3MeshMesh = meshVolume / (std::sqrt(pi) * std::pow(meshSurf, 3.0 / 2.0));
double compactness3Pixel = pixelVolume / (std::sqrt(pi) * std::pow(pixelSurface, 3.0 / 2.0));
double sphericity = std::pow(pi, 1 / 3.0) *std::pow(6 * pixelVolume, 2.0 / 3.0) / meshSurf;
double sphericityMesh = std::pow(pi, 1 / 3.0) *std::pow(6 * meshVolume, 2.0 / 3.0) / meshSurf;
double sphericityPixel = std::pow(pi, 1 / 3.0) *std::pow(6 * pixelVolume, 2.0 / 3.0) / pixelSurface;
double surfaceToVolume = meshSurf / meshVolume;
double surfaceToVolumePixel = pixelSurface / pixelVolume;
double sphericalDisproportion = meshSurf / 4 / pi / std::pow(3.0 / 4.0 / pi * pixelVolume, 2.0 / 3.0);
double sphericalDisproportionMesh = meshSurf / 4 / pi / std::pow(3.0 / 4.0 / pi * meshVolume, 2.0 / 3.0);
double sphericalDisproportionPixel = pixelSurface / 4 / pi / std::pow(3.0 / 4.0 / pi * pixelVolume, 2.0 / 3.0);
double asphericity = std::pow(1.0/compactness2, (1.0 / 3.0)) - 1;
double asphericityMesh = std::pow(1.0 / compactness2MeshMesh, (1.0 / 3.0)) - 1;
double asphericityPixel = std::pow(1.0/compactness2Pixel, (1.0 / 3.0)) - 1;
//Calculate center of mass shift
int xx = mask->GetDimensions()[0];
int yy = mask->GetDimensions()[1];
int zz = mask->GetDimensions()[2];
double xd = mask->GetGeometry()->GetSpacing()[0];
double yd = mask->GetGeometry()->GetSpacing()[1];
double zd = mask->GetGeometry()->GetSpacing()[2];
vtkSmartPointer<vtkDoubleArray> dataset1Arr = vtkSmartPointer<vtkDoubleArray>::New();
vtkSmartPointer<vtkDoubleArray> dataset2Arr = vtkSmartPointer<vtkDoubleArray>::New();
vtkSmartPointer<vtkDoubleArray> dataset3Arr = vtkSmartPointer<vtkDoubleArray>::New();
dataset1Arr->SetNumberOfComponents(1);
dataset2Arr->SetNumberOfComponents(1);
dataset3Arr->SetNumberOfComponents(1);
dataset1Arr->SetName("M1");
dataset2Arr->SetName("M2");
dataset3Arr->SetName("M3");
vtkSmartPointer<vtkDoubleArray> dataset1ArrU = vtkSmartPointer<vtkDoubleArray>::New();
vtkSmartPointer<vtkDoubleArray> dataset2ArrU = vtkSmartPointer<vtkDoubleArray>::New();
vtkSmartPointer<vtkDoubleArray> dataset3ArrU = vtkSmartPointer<vtkDoubleArray>::New();
dataset1ArrU->SetNumberOfComponents(1);
dataset2ArrU->SetNumberOfComponents(1);
dataset3ArrU->SetNumberOfComponents(1);
dataset1ArrU->SetName("M1");
dataset2ArrU->SetName("M2");
dataset3ArrU->SetName("M3");
for (int x = 0; x < xx; x++)
{
for (int y = 0; y < yy; y++)
{
for (int z = 0; z < zz; z++)
{
itk::Image<int,3>::IndexType index;
index[0] = x;
index[1] = y;
index[2] = z;
mitk::ScalarType pxImage;
mitk::ScalarType pxMask;
mitkPixelTypeMultiplex5(
mitk::FastSinglePixelAccess,
image->GetChannelDescriptor().GetPixelType(),
image,
image->GetVolumeData(),
//.........这里部分代码省略.........