本文整理汇总了C++中image::Pointer::GetPointer方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::GetPointer方法的具体用法?C++ Pointer::GetPointer怎么用?C++ Pointer::GetPointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类image::Pointer
的用法示例。
在下文中一共展示了Pointer::GetPointer方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: layer
void mitk::BinaryThresholdTool::SetupPreviewNode()
{
if (m_NodeForThresholding.IsNotNull())
{
Image::Pointer image = dynamic_cast<Image*>(m_NodeForThresholding->GetData());
Image::Pointer originalImage = dynamic_cast<Image*> (m_OriginalImageNode->GetData());
if (image.IsNotNull())
{
mitk::Image* workingimage = dynamic_cast<mitk::Image*>(m_ToolManager->GetWorkingData(0)->GetData());
if (workingimage)
{
m_ThresholdFeedbackNode->SetData(workingimage->Clone());
//Let's paint the feedback node green...
mitk::LabelSetImage::Pointer previewImage = dynamic_cast<mitk::LabelSetImage*> (m_ThresholdFeedbackNode->GetData());
itk::RGBPixel<float> pixel;
pixel[0] = 0.0f;
pixel[1] = 1.0f;
pixel[2] = 0.0f;
previewImage->GetActiveLabel()->SetColor(pixel);
previewImage->GetActiveLabelSet()->UpdateLookupTable(previewImage->GetActiveLabel()->GetValue());
}
else
m_ThresholdFeedbackNode->SetData(mitk::Image::New());
int layer(50);
m_NodeForThresholding->GetIntProperty("layer", layer);
m_ThresholdFeedbackNode->SetIntProperty("layer", layer + 1);
if (DataStorage* ds = m_ToolManager->GetDataStorage())
{
if (!ds->Exists(m_ThresholdFeedbackNode))
ds->Add(m_ThresholdFeedbackNode, m_OriginalImageNode);
}
if (image.GetPointer() == originalImage.GetPointer())
{
Image::StatisticsHolderPointer statistics = originalImage->GetStatistics();
m_SensibleMinimumThresholdValue = static_cast<double>(statistics->GetScalarValueMin());
m_SensibleMaximumThresholdValue = static_cast<double>(statistics->GetScalarValueMax());
}
if ((originalImage->GetPixelType().GetPixelType() == itk::ImageIOBase::SCALAR)
&& (originalImage->GetPixelType().GetComponentType() == itk::ImageIOBase::FLOAT || originalImage->GetPixelType().GetComponentType() == itk::ImageIOBase::DOUBLE))
m_IsFloatImage = true;
else
m_IsFloatImage = false;
m_CurrentThresholdValue = (m_SensibleMaximumThresholdValue + m_SensibleMinimumThresholdValue) / 2.0;
IntervalBordersChanged.Send(m_SensibleMinimumThresholdValue, m_SensibleMaximumThresholdValue, m_IsFloatImage);
ThresholdingValueChanged.Send(m_CurrentThresholdValue);
}
}
}
示例2: ThreadedUpdateFunction
bool CalculateSegmentationVolume::ThreadedUpdateFunction()
{
// get image
Image::Pointer image;
GetPointerParameter("Input", image);
AccessFixedDimensionByItk(image.GetPointer(),
ItkImageProcessing,
3); // some magic to call the correctly templated function (we only do 3D images here!)
// consider single voxel volume
Vector3D spacing = image->GetSlicedGeometry()->GetSpacing(); // spacing in mm
float volumeML = (ScalarType)m_Volume * spacing[0] * spacing[1] * spacing[2] / 1000.0; // convert to ml
DataNode *groupNode = GetGroupNode();
if (groupNode)
{
groupNode->SetProperty("volume", FloatProperty::New(volumeML));
groupNode->SetProperty("centerOfMass", Vector3DProperty::New(m_CenterOfMass));
groupNode->SetProperty("boundingBoxMinimum", Vector3DProperty::New(m_MinIndexOfBoundingBox));
groupNode->SetProperty("boundingBoxMaximum", Vector3DProperty::New(m_MaxIndexOfBoundingBox));
groupNode->SetProperty("showVolume", BoolProperty::New(true));
}
return true;
}
示例3: addPadding
Image::Pointer WorkbenchUtils::addPadding(Image::Pointer image, Axis axis, bool append, int numberOfSlices, float paddingPixelValue) {
// AccessByItk is a precompiler macro that sets up the instantiations for all possible template combinations. This will directly
// reflect in the compile time and required memory since functions for all permutations of PixelTypes and Dimensions will be created.
// The amount of parameters is not limited. However, a return is not possible. So we work with an out parameter:
Image::Pointer returnImage = Image::New();
AccessByItk_n(image.GetPointer(), addPaddingItk, (axis, append, numberOfSlices, paddingPixelValue, returnImage));
return returnImage;
}
示例4: resampleImage
Image::Pointer WorkbenchUtils::resampleImage(Image::Pointer image, unsigned int *newDimensions, Interpolator interpolationMethod) {
// AccessByItk is a precompiler macro that sets up the instantiations for all possible template combinations. This will directly
// reflect in the compile time and required memory since functions for all permutations of PixelTypes and Dimensions will be created.
// The amount of parameters is not limited. However, a return is not possible. So we work with an out parameter:
Image::Pointer returnImage = Image::New();
AccessByItk_n(image.GetPointer(), resampleImageItk, (interpolationMethod, newDimensions, returnImage));
return returnImage;
}
示例5: CastToItkImage
void mitk::CollectionGrayOpening::PerformGrayOpening(mitk::DataCollection *dataCollection,
std::string name,
std::string suffix)
{
for (size_t patient = 0; patient < dataCollection->Size(); ++patient)
{
DataCollection *dataPatient = dynamic_cast<DataCollection *>(dataCollection->GetData(patient).GetPointer());
if (dataPatient == nullptr)
MITK_ERROR << "PerformGrayOpening - Structure of DataCollection is invalid at patient level. Data inconsistent!";
if (dataPatient->Size() == 0)
MITK_ERROR << "Empty Patient Collective. Probably Fatal.";
for (size_t timeStep = 0; timeStep < dataPatient->Size(); ++timeStep)
{
DataCollection *dataTimeStep = dynamic_cast<DataCollection *>(dataPatient->GetData(timeStep).GetPointer());
if (dataTimeStep == nullptr)
MITK_ERROR
<< "DilateBinaryByName- Structure of DataCollection is invalid at time step level. Data inconsistent!";
// BinaryImage::Pointer itkImage = BinaryImage::New();
ImageType::Pointer itkImage = ImageType::New();
Image::Pointer tmp = dataTimeStep->GetMitkImage(name).GetPointer();
if (tmp.IsNull())
MITK_ERROR << "null";
CastToItkImage(tmp, itkImage);
if (itkImage.IsNull())
MITK_ERROR << "Image " << name << " does not exist. Fatal.";
typedef itk::FlatStructuringElement<3> StructuringElementType;
StructuringElementType::RadiusType elementRadius;
elementRadius.Fill(1);
elementRadius[2] = 0;
StructuringElementType structuringElement = StructuringElementType::Box(elementRadius);
typedef itk::GrayscaleMorphologicalOpeningImageFilter<ImageType, ImageType, StructuringElementType>
DilateImageFilterType;
DilateImageFilterType::Pointer dilateFilter0 = DilateImageFilterType::New();
dilateFilter0->SetInput(itkImage);
dilateFilter0->SetKernel(structuringElement);
dilateFilter0->Update();
DilateImageFilterType::Pointer dilateFilter1 = DilateImageFilterType::New();
dilateFilter1->SetInput(dilateFilter0->GetOutput());
dilateFilter1->SetKernel(structuringElement);
dilateFilter1->Update();
Image::Pointer dil = GrabItkImageMemory(dilateFilter1->GetOutput());
dataTimeStep->AddData(dil.GetPointer(), name + suffix, "");
}
}
}
示例6: layer
void mitk::BinaryThresholdULTool::SetupPreviewNode()
{
if (m_NodeForThresholding.IsNotNull())
{
Image::Pointer image = dynamic_cast<Image*>( m_NodeForThresholding->GetData() );
Image::Pointer originalImage = dynamic_cast<Image*> (m_OriginalImageNode->GetData());
if (image.IsNotNull())
{
mitk::Image* workingimage = dynamic_cast<mitk::Image*>(m_ToolManager->GetWorkingData(0)->GetData());
if(workingimage)
m_ThresholdFeedbackNode->SetData( workingimage->Clone() );
else
m_ThresholdFeedbackNode->SetData( mitk::Image::New() );
int layer(50);
m_NodeForThresholding->GetIntProperty("layer", layer);
m_ThresholdFeedbackNode->SetIntProperty("layer", layer+1);
if (DataStorage* ds = m_ToolManager->GetDataStorage())
{
if (!ds->Exists(m_ThresholdFeedbackNode))
ds->Add( m_ThresholdFeedbackNode, m_OriginalImageNode );
}
if (image.GetPointer() == originalImage.GetPointer())
{
m_SensibleMinimumThresholdValue = static_cast<double>( originalImage->GetScalarValueMin() );
m_SensibleMaximumThresholdValue = static_cast<double>( originalImage->GetScalarValueMax() );
}
m_CurrentLowerThresholdValue = (m_SensibleMaximumThresholdValue + m_SensibleMinimumThresholdValue) / 3.0;
m_CurrentUpperThresholdValue = 2.0 * m_CurrentLowerThresholdValue;
IntervalBordersChanged.Send(m_SensibleMinimumThresholdValue, m_SensibleMaximumThresholdValue);
ThresholdingValuesChanged.Send(m_CurrentLowerThresholdValue, m_CurrentUpperThresholdValue);
}
}
}
示例7: layer
void mitk::BinaryThresholdULTool::SetupPreviewNode()
{
if (m_NodeForThresholding.IsNotNull())
{
Image::Pointer image = dynamic_cast<Image*>( m_NodeForThresholding->GetData() );
Image::Pointer originalImage = dynamic_cast<Image*> (m_OriginalImageNode->GetData());
if (image.IsNotNull())
{
// initialize and a new node with the same image as our reference image
// use the level window property of this image copy to display the result of a thresholding operation
m_ThresholdFeedbackNode->SetData( image );
int layer(50);
m_NodeForThresholding->GetIntProperty("layer", layer);
m_ThresholdFeedbackNode->SetIntProperty("layer", layer+1);
if (DataStorage* ds = m_ToolManager->GetDataStorage())
{
if (!ds->Exists(m_ThresholdFeedbackNode))
ds->Add( m_ThresholdFeedbackNode, m_OriginalImageNode );
}
if (image.GetPointer() == originalImage.GetPointer())
{
m_SensibleMinimumThresholdValue = static_cast<int>( originalImage->GetScalarValueMin() );
m_SensibleMaximumThresholdValue = static_cast<int>( originalImage->GetScalarValueMax() );
}
m_CurrentLowerThresholdValue = (m_SensibleMaximumThresholdValue + m_SensibleMinimumThresholdValue) / 3;
m_CurrentUpperThresholdValue = 2*m_CurrentLowerThresholdValue;
IntervalBordersChanged.Send(m_SensibleMinimumThresholdValue, m_SensibleMaximumThresholdValue);
ThresholdingValuesChanged.Send(m_CurrentLowerThresholdValue, m_CurrentUpperThresholdValue);
}
}
}
示例8: localeSwitch
//.........这里部分代码省略.........
{
arbitraryTimeGeometry->AppendTimeStepClone(slicedGeometry, *pos, *prePos);
}
timeGeometry = arbitraryTimeGeometry;
}
}
}
if (timeGeometry.IsNull())
{ // Fallback. If no other valid time geometry has been created, create a ProportionalTimeGeometry
MITK_INFO << "used time geometry: " << ProportionalTimeGeometry::GetStaticNameOfClass() << std::endl;
ProportionalTimeGeometry::Pointer propTimeGeometry = ProportionalTimeGeometry::New();
propTimeGeometry->Initialize(slicedGeometry, image->GetDimension(3));
timeGeometry = propTimeGeometry;
}
image->SetTimeGeometry(timeGeometry);
buffer = NULL;
MITK_INFO << "number of image components: " << image->GetPixelType().GetNumberOfComponents() << std::endl;
for (itk::MetaDataDictionary::ConstIterator iter = dictionary.Begin(), iterEnd = dictionary.End(); iter != iterEnd;
++iter)
{
if (iter->second->GetMetaDataObjectTypeInfo() == typeid(std::string))
{
const std::string &key = iter->first;
std::string assumedPropertyName = key;
std::replace(assumedPropertyName.begin(), assumedPropertyName.end(), '_', '.');
std::string mimeTypeName = GetMimeType()->GetName();
// Check if there is already a info for the key and our mime type.
IPropertyPersistence::InfoResultType infoList = mitk::CoreServices::GetPropertyPersistence()->GetInfoByKey(key);
auto predicate = [mimeTypeName](const PropertyPersistenceInfo::ConstPointer &x) {
return x.IsNotNull() && x->GetMimeTypeName() == mimeTypeName;
};
auto finding = std::find_if(infoList.begin(), infoList.end(), predicate);
if (finding == infoList.end())
{
auto predicateWild = [](const PropertyPersistenceInfo::ConstPointer &x) {
return x.IsNotNull() && x->GetMimeTypeName() == PropertyPersistenceInfo::ANY_MIMETYPE_NAME();
};
finding = std::find_if(infoList.begin(), infoList.end(), predicateWild);
}
PropertyPersistenceInfo::ConstPointer info;
if (finding != infoList.end())
{
assumedPropertyName = (*finding)->GetName();
info = *finding;
}
else
{ // we have not found anything suitable so we generate our own info
PropertyPersistenceInfo::Pointer newInfo = PropertyPersistenceInfo::New();
newInfo->SetNameAndKey(assumedPropertyName, key);
newInfo->SetMimeTypeName(PropertyPersistenceInfo::ANY_MIMETYPE_NAME());
info = newInfo;
}
std::string value =
dynamic_cast<itk::MetaDataObject<std::string> *>(iter->second.GetPointer())->GetMetaDataObjectValue();
mitk::BaseProperty::Pointer loadedProp = info->GetDeserializationFunction()(value);
image->SetProperty(assumedPropertyName.c_str(), loadedProp);
// Read properties should be persisted unless they are default properties
// which are written anyway
bool isDefaultKey(false);
for (const auto &defaultKey : m_DefaultMetaDataKeys)
{
if (defaultKey.length() <= assumedPropertyName.length())
{
// does the start match the default key
if (assumedPropertyName.substr(0, defaultKey.length()).find(defaultKey) != std::string::npos)
{
isDefaultKey = true;
break;
}
}
}
if (!isDefaultKey)
{
mitk::CoreServices::GetPropertyPersistence()->AddInfo(info);
}
}
}
MITK_INFO << "...finished!" << std::endl;
result.push_back(image.GetPointer());
return result;
}
示例9: itkExceptionMacro
void mitk::CorrectorAlgorithm::GenerateData()
{
Image::Pointer inputImage = const_cast<Image*>(ImageToImageFilter::GetInput(0));
if (inputImage.IsNull() || inputImage->GetDimension() != 2)
{
itkExceptionMacro("CorrectorAlgorithm needs a 2D image as input.");
}
if (m_Contour.IsNull())
{
itkExceptionMacro("CorrectorAlgorithm needs a Contour object as input.");
}
// copy the input (since m_WorkingImage will be changed later)
m_WorkingImage = Image::New();
m_WorkingImage->Initialize( inputImage );
m_WorkingImage->SetVolume( inputImage.GetPointer()->GetData() );
if (inputImage->GetTimeSlicedGeometry() )
{
AffineGeometryFrame3D::Pointer originalGeometryAGF = inputImage->GetTimeSlicedGeometry()->Clone();
TimeSlicedGeometry::Pointer originalGeometry = dynamic_cast<TimeSlicedGeometry*>( originalGeometryAGF.GetPointer() );
m_WorkingImage->SetGeometry( originalGeometry );
}
else
{
itkExceptionMacro("Original image does not have a 'Time sliced geometry'! Cannot copy.");
}
// Convert to ipMITKSegmentationTYPE (because TobiasHeimannCorrectionAlgorithm relys on that data type)
itk::Image< ipMITKSegmentationTYPE, 2 >::Pointer correctPixelTypeImage;
CastToItkImage( m_WorkingImage, correctPixelTypeImage );
assert (correctPixelTypeImage.IsNotNull() );
// possible bug in CastToItkImage ?
// direction maxtrix is wrong/broken/not working after CastToItkImage, leading to a failed assertion in
// mitk/Core/DataStructures/mitkSlicedGeometry3D.cpp, 479:
// virtual void mitk::SlicedGeometry3D::SetSpacing(const mitk::Vector3D&): Assertion `aSpacing[0]>0 && aSpacing[1]>0 && aSpacing[2]>0' failed
// solution here: we overwrite it with an unity matrix
itk::Image< ipMITKSegmentationTYPE, 2 >::DirectionType imageDirection;
imageDirection.SetIdentity();
correctPixelTypeImage->SetDirection(imageDirection);
Image::Pointer temporarySlice = this->GetOutput();
// temporarySlice = ImportItkImage( correctPixelTypeImage );
CastToMitkImage( correctPixelTypeImage, temporarySlice );
TobiasHeimannCorrectionAlgorithm( temporarySlice->GetSliceData()->GetPicDescriptor() );
// temporarySlice is our return value (user can get it by calling GetOutput() )
CalculateDifferenceImage( temporarySlice, inputImage );
if ( m_DifferenceImage.IsNotNull() && inputImage->GetTimeSlicedGeometry() )
{
AffineGeometryFrame3D::Pointer originalGeometryAGF = inputImage->GetTimeSlicedGeometry()->Clone();
TimeSlicedGeometry::Pointer originalGeometry = dynamic_cast<TimeSlicedGeometry*>( originalGeometryAGF.GetPointer() );
m_DifferenceImage->SetGeometry( originalGeometry );
}
else
{
itkExceptionMacro("Original image does not have a 'Time sliced geometry'! Cannot copy.");
}
}
示例10: ioRegion
//.........这里部分代码省略.........
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 )
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);
MITK_INFO << slicedGeometry->GetCornerPoint(false,false,false);
MITK_INFO << slicedGeometry->GetCornerPoint(true,true,true);
// re-initialize TimeGeometry
ProportionalTimeGeometry::Pointer timeGeometry = ProportionalTimeGeometry::New();
timeGeometry->Initialize(slicedGeometry, image->GetDimension(3));
image->SetTimeGeometry(timeGeometry);
buffer = NULL;
MITK_INFO << "number of image components: "<< image->GetPixelType().GetNumberOfComponents() << std::endl;
const itk::MetaDataDictionary& dictionary = m_ImageIO->GetMetaDataDictionary();
for (itk::MetaDataDictionary::ConstIterator iter = dictionary.Begin(), iterEnd = dictionary.End();
iter != iterEnd; ++iter)
{
std::string key = std::string("meta.") + iter->first;
if (iter->second->GetMetaDataObjectTypeInfo() == typeid(std::string))
{
std::string value = dynamic_cast<itk::MetaDataObject<std::string>*>(iter->second.GetPointer())->GetMetaDataObjectValue();
image->SetProperty(key.c_str(), mitk::StringProperty::New(value));
}
}
MITK_INFO << "...finished!" << std::endl;
try
{
setlocale(LC_ALL, currLocale.c_str());
}
catch(...)
{
MITK_INFO << "Could not reset locale " << currLocale;
}
result.push_back(image.GetPointer());
return result;
}