本文整理汇总了C++中image::Pointer类的典型用法代码示例。如果您正苦于以下问题:C++ Pointer类的具体用法?C++ Pointer怎么用?C++ Pointer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Pointer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTargetSegmentationNode
void mitk::BinaryThresholdULTool::CreateNewSegmentationFromThreshold(DataNode* node)
{
if (node)
{
Image::Pointer feedBackImage = dynamic_cast<Image*>( m_ThresholdFeedbackNode->GetData() );
if (feedBackImage.IsNotNull())
{
// create a new image of the same dimensions and smallest possible pixel type
DataNode::Pointer emptySegmentation = GetTargetSegmentationNode();
if (emptySegmentation)
{
// actually perform a thresholding and ask for an organ type
for (unsigned int timeStep = 0; timeStep < feedBackImage->GetTimeSteps(); ++timeStep)
{
try
{
ImageTimeSelector::Pointer timeSelector = ImageTimeSelector::New();
timeSelector->SetInput( feedBackImage );
timeSelector->SetTimeNr( timeStep );
timeSelector->UpdateLargestPossibleRegion();
Image::Pointer feedBackImage3D = timeSelector->GetOutput();
if (feedBackImage3D->GetDimension() == 2)
{
AccessFixedDimensionByItk_2( feedBackImage3D, ITKSetVolume, 2, dynamic_cast<Image*>(emptySegmentation->GetData()), timeStep );
}
else
{
AccessFixedDimensionByItk_2( feedBackImage3D, ITKSetVolume, 3, dynamic_cast<Image*>(emptySegmentation->GetData()), timeStep );
}
}
catch(...)
{
Tool::ErrorMessage("Error accessing single time steps of the original image. Cannot create segmentation.");
}
}
//since we are maybe working on a smaller image, pad it to the size of the original image
if (m_OriginalImageNode.GetPointer() != m_NodeForThresholding.GetPointer())
{
mitk::PadImageFilter::Pointer padFilter = mitk::PadImageFilter::New();
padFilter->SetInput(0, dynamic_cast<mitk::Image*> (emptySegmentation->GetData()));
padFilter->SetInput(1, dynamic_cast<mitk::Image*> (m_OriginalImageNode->GetData()));
padFilter->SetBinaryFilter(true);
padFilter->SetUpperThreshold(1);
padFilter->SetLowerThreshold(1);
padFilter->Update();
emptySegmentation->SetData(padFilter->GetOutput());
}
m_ToolManager->SetWorkingData( emptySegmentation );
m_ToolManager->GetWorkingData(0)->Modified();
}
}
}
}
示例2: job_test
void job_test()
{
typedef itk::Image<int,3> Image;
typedef itk::ImageFileReader<Image> Reader;
// Read in the image (when debugging in VC++, it may be necessary to set the working directory to "$(TargetDir)").
std::cout << "Loading input image...\n";
Reader::Pointer reader = Reader::New();
reader->SetFileName("../resources/test.bmp");
reader->Update();
Image::Pointer image = reader->GetOutput();
// Create a DICOM volume (obviously not a proper one, as the image being read in is actually a greyscale one).
DICOMVolume_Ptr volume(new DICOMVolume(image));
// Set the segmentation options.
itk::Size<3> size = image->GetLargestPossibleRegion().GetSize();
WindowSettings windowSettings(40, 400); // dummy window settings
CTSegmentationOptions options(30, CTSegmentationOptions::INPUTTYPE_HOUNSFIELD, size, 10, windowSettings);
// Build the IPF.
std::cout << "Building IPF...\n";
typedef CTIPFBuilder::IPF_Ptr IPF_Ptr;
IPF_Ptr ipf;
Job_Ptr job(new CTIPFBuilder(volume, options, ipf));
Job::execute_in_thread(job);
while(!job->is_finished());
// Output the mosaic images for each of the partition forest layers.
std::cout << "Outputting mosaic images...\n";
for(int i=0; i<=ipf->highest_layer(); ++i)
{
output_mosaic_image(ipf, i, size[0], size[1]);
}
}
示例3:
//#################### HELPER FUNCTIONS ####################
itk::Image<unsigned char,2>::Pointer make_mosaic_image(const boost::shared_ptr<const PartitionForest<CTImageLeafLayer,CTImageBranchLayer> >& ipf, int layerIndex,
int width, int height)
{
typedef itk::Image<unsigned char,2> Image;
typedef PartitionForest<CTImageLeafLayer,CTImageBranchLayer> IPF;
Image::Pointer image = ITKImageUtil::make_image<unsigned char>(width, height);
Image::IndexType index;
int n = 0;
for(index[1]=0; index[1]<height; ++index[1])
for(index[0]=0; index[0]<width; ++index[0])
{
unsigned char mosaicValue;
if(layerIndex > 0)
{
PFNodeID ancestor = ipf->ancestor_of(PFNodeID(0, n), layerIndex);
mosaicValue = static_cast<unsigned char>(ipf->branch_properties(ancestor).mean_grey_value());
}
else mosaicValue = ipf->leaf_properties(n).grey_value();
image->SetPixel(index, mosaicValue);
++n;
}
return image;
}
示例4: ReadyToRun
bool CalculateSegmentationVolume::ReadyToRun()
{
Image::Pointer image;
GetPointerParameter("Input", image);
return image.IsNotNull() && GetGroupNode();
}
示例5: workingNode
void mitk::SegTool2D::WriteBackSegmentationResult(std::vector<mitk::SegTool2D::SliceInformation> sliceList, bool writeSliceToVolume)
{
std::vector<mitk::Surface::Pointer> contourList;
contourList.reserve(sliceList.size());
ImageToContourFilter::Pointer contourExtractor = ImageToContourFilter::New();
DataNode* workingNode( m_ToolManager->GetWorkingData(0) );
Image* image = dynamic_cast<Image*>(workingNode->GetData());
mitk::ImageTimeSelector::Pointer timeSelector = mitk::ImageTimeSelector::New();
timeSelector->SetInput( image );
timeSelector->SetTimeNr( 0 );
timeSelector->SetChannelNr( 0 );
timeSelector->Update();
Image::Pointer dimRefImg = timeSelector->GetOutput();
for (unsigned int i = 0; i < sliceList.size(); ++i)
{
SliceInformation currentSliceInfo = sliceList.at(i);
if(writeSliceToVolume)
this->WriteSliceToVolume(currentSliceInfo);
if (m_SurfaceInterpolationEnabled && dimRefImg->GetDimension() == 3)
{
currentSliceInfo.slice->DisconnectPipeline();
contourExtractor->SetInput(currentSliceInfo.slice);
contourExtractor->Update();
mitk::Surface::Pointer contour = contourExtractor->GetOutput();
contour->DisconnectPipeline();
contourList.push_back(contour);
}
}
mitk::SurfaceInterpolationController::GetInstance()->AddNewContours(contourList);
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
}
示例6: 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;
}
示例7:
/*
* What is the input requested region that is required to produce the output
* requested region? By default, the largest possible region is always
* required but this is overridden in many subclasses. For instance, for an
* image processing filter where an output pixel is a simple function of an
* input pixel, the input requested region will be set to the output
* requested region. For an image processing filter where an output pixel is
* a function of the pixels in a neighborhood of an input pixel, then the
* input requested region will need to be larger than the output requested
* region (to avoid introducing artificial boundary conditions). This
* function should never request an input region that is outside the the
* input largest possible region (i.e. implementations of this method should
* crop the input requested region at the boundaries of the input largest
* possible region).
*/
void mitk::ExtractImageFilter::GenerateInputRequestedRegion()
{
Superclass::GenerateInputRequestedRegion();
ImageToImageFilter::InputImagePointer input = const_cast< ImageToImageFilter::InputImageType* > ( this->GetInput() );
Image::Pointer output = this->GetOutput();
if (input->GetDimension() == 2)
{
input->SetRequestedRegionToLargestPossibleRegion();
return;
}
Image::RegionType requestedRegion;
requestedRegion = output->GetRequestedRegion();
requestedRegion.SetIndex(0, 0);
requestedRegion.SetIndex(1, 0);
requestedRegion.SetIndex(2, 0);
requestedRegion.SetSize(0, input->GetDimension(0));
requestedRegion.SetSize(1, input->GetDimension(1));
requestedRegion.SetSize(2, input->GetDimension(2));
requestedRegion.SetIndex( m_SliceDimension, m_SliceIndex ); // only one slice needed
requestedRegion.SetSize( m_SliceDimension, 1 );
input->SetRequestedRegion( &requestedRegion );
}
示例8:
void mitk::GeometryClipImageFilter::GenerateData()
{
Image::ConstPointer input = this->GetInput();
Image::Pointer output = this->GetOutput();
if((output->IsInitialized()==false) || (m_ClippingGeometry.IsNull()))
return;
const Geometry2D * clippingGeometryOfCurrentTimeStep = NULL;
if(m_TimeSlicedClippingGeometry.IsNull())
{
clippingGeometryOfCurrentTimeStep = dynamic_cast<const Geometry2D*>(m_ClippingGeometry.GetPointer());
}
else
{
clippingGeometryOfCurrentTimeStep = dynamic_cast<const Geometry2D*>(m_TimeSlicedClippingGeometry->GetGeometry3D(0));
}
if(clippingGeometryOfCurrentTimeStep == NULL)
return;
m_InputTimeSelector->SetInput(input);
m_OutputTimeSelector->SetInput(this->GetOutput());
mitk::Image::RegionType outputRegion = output->GetRequestedRegion();
const mitk::TimeSlicedGeometry *outputTimeGeometry = output->GetTimeSlicedGeometry();
const mitk::TimeSlicedGeometry *inputTimeGeometry = input->GetTimeSlicedGeometry();
ScalarType timeInMS;
int timestep=0;
int tstart=outputRegion.GetIndex(3);
int tmax=tstart+outputRegion.GetSize(3);
int t;
for(t=tstart;t<tmax;++t)
{
timeInMS = outputTimeGeometry->TimeStepToMS( t );
timestep = inputTimeGeometry->MSToTimeStep( timeInMS );
m_InputTimeSelector->SetTimeNr(timestep);
m_InputTimeSelector->UpdateLargestPossibleRegion();
m_OutputTimeSelector->SetTimeNr(t);
m_OutputTimeSelector->UpdateLargestPossibleRegion();
if(m_TimeSlicedClippingGeometry.IsNotNull())
{
timestep = m_TimeSlicedClippingGeometry->MSToTimeStep( timeInMS );
if(m_TimeSlicedClippingGeometry->IsValidTime(timestep) == false)
continue;
clippingGeometryOfCurrentTimeStep = dynamic_cast<const Geometry2D*>(m_TimeSlicedClippingGeometry->GetGeometry3D(timestep));
}
AccessByItk_2(m_InputTimeSelector->GetOutput(),_InternalComputeClippedImage,this,clippingGeometryOfCurrentTimeStep);
}
m_TimeOfHeaderInitialization.Modified();
}
示例9: ComputeIntensityProfile
static IntensityProfile::Pointer ComputeIntensityProfile(Image::Pointer image, itk::PolyLineParametricPath<3>::Pointer path)
{
IntensityProfile::Pointer intensityProfile = IntensityProfile::New();
itk::PolyLineParametricPath<3>::InputType input = path->StartOfInput();
BaseGeometry* imageGeometry = image->GetGeometry();
const PixelType pixelType = image->GetPixelType();
IntensityProfile::MeasurementVectorType measurementVector;
itk::PolyLineParametricPath<3>::OffsetType offset;
Point3D worldPoint;
itk::Index<3> index;
do
{
imageGeometry->IndexToWorld(path->Evaluate(input), worldPoint);
imageGeometry->WorldToIndex(worldPoint, index);
mitkPixelTypeMultiplex3(ReadPixel, pixelType, image, index, measurementVector.GetDataPointer());
intensityProfile->PushBack(measurementVector);
offset = path->IncrementInput(input);
} while ((offset[0] | offset[1] | offset[2]) != 0);
return intensityProfile;
}
示例10: iterator_label
ImageBinary::Pointer label2mask(Image::Pointer label, unsigned int element)
{
ImageBinary::Pointer mask = ImageBinary::New();
Image::RegionType region = label->GetLargestPossibleRegion();
mask->SetRegions(region);
mask->Allocate();
mask->FillBuffer(0);
ConstIterator iterator_label(label, label->GetLargestPossibleRegion());
IteratorBinary iterator_mask(mask, mask->GetLargestPossibleRegion());
try
{
while(!iterator_label.IsAtEnd())
{
if(iterator_label.Get() == element && element || iterator_label.Get() != 0 && !element)
iterator_mask.Set(1);
++iterator_label; ++iterator_mask;
}
}
catch(itk::ExceptionObject & err)
{
std::cerr<<"Exception caught, outside bounds using iterators"<<std::endl;
std::cerr<<err<<std::endl;
}
return mask;
}
示例11:
void mitk::SegTool2D::UpdateSurfaceInterpolation(const Image *slice,
const Image *workingImage,
const PlaneGeometry *plane,
bool detectIntersection)
{
if (!m_SurfaceInterpolationEnabled)
return;
ImageToContourFilter::Pointer contourExtractor = ImageToContourFilter::New();
mitk::Surface::Pointer contour;
if (detectIntersection)
{
// Test whether there is something to extract or whether the slice just contains intersections of others
mitk::Image::Pointer slice2 = slice->Clone();
mitk::MorphologicalOperations::Erode(slice2, 2, mitk::MorphologicalOperations::Ball);
contourExtractor->SetInput(slice2);
contourExtractor->Update();
contour = contourExtractor->GetOutput();
if (contour->GetVtkPolyData()->GetNumberOfPoints() == 0)
{
// Remove contour!
mitk::SurfaceInterpolationController::ContourPositionInformation contourInfo;
contourInfo.contourNormal = plane->GetNormal();
contourInfo.contourPoint = plane->GetOrigin();
mitk::SurfaceInterpolationController::GetInstance()->RemoveContour(contourInfo);
return;
}
}
contourExtractor->SetInput(slice);
contourExtractor->Update();
contour = contourExtractor->GetOutput();
mitk::ImageTimeSelector::Pointer timeSelector = mitk::ImageTimeSelector::New();
timeSelector->SetInput(workingImage);
timeSelector->SetTimeNr(0);
timeSelector->SetChannelNr(0);
timeSelector->Update();
Image::Pointer dimRefImg = timeSelector->GetOutput();
if (contour->GetVtkPolyData()->GetNumberOfPoints() != 0 && dimRefImg->GetDimension() == 3)
{
mitk::SurfaceInterpolationController::GetInstance()->AddNewContour(contour);
contour->DisconnectPipeline();
}
else
{
// Remove contour!
mitk::SurfaceInterpolationController::ContourPositionInformation contourInfo;
contourInfo.contourNormal = plane->GetNormal();
contourInfo.contourPoint = plane->GetOrigin();
mitk::SurfaceInterpolationController::GetInstance()->RemoveContour(contourInfo);
}
}
示例12: catch
void mitk::BinaryThresholdULTool::CreateNewSegmentationFromThreshold(DataNode* node, const std::string& organName, const Color& color)
{
if (node)
{
Image::Pointer image = dynamic_cast<Image*>( m_NodeForThresholding->GetData() );
if (image.IsNotNull())
{
// create a new image of the same dimensions and smallest possible pixel type
DataNode::Pointer emptySegmentation = Tool::CreateEmptySegmentationNode( image, organName, color );
if (emptySegmentation)
{
// actually perform a thresholding and ask for an organ type
for (unsigned int timeStep = 0; timeStep < image->GetTimeSteps(); ++timeStep)
{
try
{
ImageTimeSelector::Pointer timeSelector = ImageTimeSelector::New();
timeSelector->SetInput( image );
timeSelector->SetTimeNr( timeStep );
timeSelector->UpdateLargestPossibleRegion();
Image::Pointer image3D = timeSelector->GetOutput();
AccessFixedDimensionByItk_2( image3D, ITKThresholding, 3, dynamic_cast<Image*>(emptySegmentation->GetData()), timeStep );
}
catch(...)
{
Tool::ErrorMessage("Error accessing single time steps of the original image. Cannot create segmentation.");
}
}
//since we are maybe working on a smaller image, pad it to the size of the original image
if (m_OriginalImageNode.GetPointer() != m_NodeForThresholding.GetPointer())
{
mitk::PadImageFilter::Pointer padFilter = mitk::PadImageFilter::New();
padFilter->SetInput(0, dynamic_cast<mitk::Image*> (emptySegmentation->GetData()));
padFilter->SetInput(1, dynamic_cast<mitk::Image*> (m_OriginalImageNode->GetData()));
padFilter->SetBinaryFilter(true);
padFilter->SetUpperThreshold(1);
padFilter->SetLowerThreshold(1);
padFilter->Update();
emptySegmentation->SetData(padFilter->GetOutput());
}
if (DataStorage* ds = m_ToolManager->GetDataStorage())
{
ds->Add( emptySegmentation, m_OriginalImageNode );
}
m_ToolManager->SetWorkingData( emptySegmentation );
}
}
}
}
示例13: ReadyToRun
bool SegmentationSink::ReadyToRun()
{
Image::Pointer image;
GetPointerParameter("Input", image);
DataNode::Pointer groupNode;
GetPointerParameter("Group node", groupNode);
return image.IsNotNull() && groupNode.IsNotNull();
}
示例14: timeStep
mitk::Image::Pointer mitk::CompressedImageContainer::GetImage()
{
if (m_ByteBuffers.empty())
return nullptr;
// uncompress image data, create an Image
Image::Pointer image = Image::New();
unsigned int dims[20]; // more than 20 dimensions and bang
for (unsigned int dim = 0; dim < m_ImageDimension; ++dim)
dims[dim] = m_ImageDimensions[dim];
image->Initialize(*m_PixelType, m_ImageDimension, dims); // this IS needed, right ?? But it does allocate memory ->
// does create one big lump of memory (also in windows)
unsigned int timeStep(0);
for (auto iter = m_ByteBuffers.begin(); iter != m_ByteBuffers.end(); ++iter, ++timeStep)
{
ImageReadAccessor imgAcc(image, image->GetVolumeData(timeStep));
auto *dest((unsigned char *)imgAcc.GetData());
::uLongf destLen(m_OneTimeStepImageSizeInBytes);
::Bytef *source(iter->first);
::uLongf sourceLen(iter->second);
int zlibRetVal = ::uncompress(dest, &destLen, source, sourceLen);
if (itk::Object::GetDebug())
{
if (zlibRetVal == Z_OK)
{
MITK_INFO << "Success, destLen now " << destLen << " bytes" << std::endl;
}
else
{
switch (zlibRetVal)
{
case Z_DATA_ERROR:
MITK_ERROR << "compressed data corrupted" << std::endl;
break;
case Z_MEM_ERROR:
MITK_ERROR << "not enough memory" << std::endl;
break;
case Z_BUF_ERROR:
MITK_ERROR << "output buffer too small" << std::endl;
break;
default:
MITK_ERROR << "other, unspecified error" << std::endl;
break;
}
}
}
}
image->SetGeometry(m_ImageGeometry);
image->Modified();
return image;
}
示例15: sliceDimension
/*
* Generate the information decribing the output data. The default
* implementation of this method will copy information from the input to the
* output. A filter may override this method if its output will have different
* information than its input. For instance, a filter that shrinks an image will
* need to provide an implementation for this method that changes the spacing of
* the pixels. Such filters should call their superclass' implementation of this
* method prior to changing the information values they need (i.e.
* GenerateOutputInformation() should call
* Superclass::GenerateOutputInformation() prior to changing the information.
*/
void mitk::ExtractImageFilter::GenerateOutputInformation()
{
Image::Pointer output = this->GetOutput();
Image::ConstPointer input = this->GetInput();
if (input.IsNull()) return;
if ( m_SliceDimension >= input->GetDimension() && input->GetDimension() != 2 )
{
MITK_ERROR << "mitk::ExtractImageFilter:GenerateOutputInformation m_SliceDimension == " << m_SliceDimension << " makes no sense with an " << input->GetDimension() << "D image." << std::endl;
itkExceptionMacro("This is not a sensible value for m_SliceDimension.");
return;
}
unsigned int sliceDimension( m_SliceDimension );
if ( input->GetDimension() == 2)
{
sliceDimension = 2;
}
unsigned int tmpDimensions[2];
switch ( sliceDimension )
{
default:
case 2:
// orientation = PlaneGeometry::Axial;
tmpDimensions[0] = input->GetDimension(0);
tmpDimensions[1] = input->GetDimension(1);
break;
case 1:
// orientation = PlaneGeometry::Frontal;
tmpDimensions[0] = input->GetDimension(0);
tmpDimensions[1] = input->GetDimension(2);
break;
case 0:
// orientation = PlaneGeometry::Sagittal;
tmpDimensions[0] = input->GetDimension(1);
tmpDimensions[1] = input->GetDimension(2);
break;
}
output->Initialize(input->GetPixelType(), 2, tmpDimensions, 1 /*input->GetNumberOfChannels()*/);
// initialize the spacing of the output
/*
Vector3D spacing = input->GetSlicedGeometry()->GetSpacing();
if(input->GetDimension()>=2)
spacing[2]=spacing[1];
else
spacing[2] = 1.0;
output->GetSlicedGeometry()->SetSpacing(spacing);
*/
output->SetPropertyList(input->GetPropertyList()->Clone());
}