本文整理汇总了C++中mitk::image::Pointer类的典型用法代码示例。如果您正苦于以下问题:C++ Pointer类的具体用法?C++ Pointer怎么用?C++ Pointer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Pointer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetImageStatisticsWithImageAndMaskNotConnected
void GetImageStatisticsWithImageAndMaskNotConnected()
{
//create rules connection + add statistics to dataStorage
auto statisticsNode = mitk::CreateImageStatisticsNode(m_statisticsContainer, "testStatistics");
CreateNodeRelationImage(m_statisticsContainer.GetPointer(), m_image.GetPointer());
CreateNodeRelationMask(m_statisticsContainer.GetPointer(), m_mask.GetPointer());
auto standaloneDataStorage = mitk::StandaloneDataStorage::New();
standaloneDataStorage->Add(statisticsNode);
//rule: (image-->statistics, mask-->statistics), 1 connected image --> test return nullptr
mitk::ImageStatisticsContainer::ConstPointer statisticsWithImage;
CPPUNIT_ASSERT_NO_THROW(statisticsWithImage = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image.GetPointer()));
CPPUNIT_ASSERT_EQUAL(statisticsWithImage.IsNull(), true);
//rule: (image-->statistics, mask-->statistics), 1 unconnected image, 1 unconnected mask --> test return nullptr
mitk::ImageStatisticsContainer::ConstPointer statisticsWithImageNotConnectedAndMaskNotConnected;
CPPUNIT_ASSERT_NO_THROW(statisticsWithImageNotConnectedAndMaskNotConnected = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image2.GetPointer(), m_mask2.GetPointer()));
CPPUNIT_ASSERT_EQUAL(statisticsWithImageNotConnectedAndMaskNotConnected.IsNull(), true);
//rule: (image-->statistics, mask-->statistics), 1 unconnected image, 1 connected mask --> test return nullptr
mitk::ImageStatisticsContainer::ConstPointer statisticsWithImageAndMaskNotConnected;
CPPUNIT_ASSERT_NO_THROW(statisticsWithImageAndMaskNotConnected = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image2.GetPointer(), m_mask.GetPointer()));
CPPUNIT_ASSERT_EQUAL(statisticsWithImageAndMaskNotConnected.IsNull(), true);
//rule: (image-->statistics, mask-->statistics), 1 connected image, 1 unconnected planarFigure --> test return nullptr
mitk::ImageStatisticsContainer::ConstPointer statisticsWithImageAndPlanarFigureNotConnected;
CPPUNIT_ASSERT_NO_THROW(statisticsWithImageAndPlanarFigureNotConnected = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image.GetPointer(), m_planarFigure.GetPointer()));
CPPUNIT_ASSERT_EQUAL(statisticsWithImageAndPlanarFigureNotConnected.IsNull(), true);
//rule: (image-->statistics, mask-->statistics), 1 unconnected image, 1 unconnected planarFigure --> test return nullptr
mitk::ImageStatisticsContainer::ConstPointer statisticsWithImageNotConnectedAndPlanarFigureNotConnected;
CPPUNIT_ASSERT_NO_THROW(statisticsWithImageAndPlanarFigureNotConnected = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image2.GetPointer(), m_planarFigure.GetPointer()));
CPPUNIT_ASSERT_EQUAL(statisticsWithImageAndPlanarFigureNotConnected.IsNull(), true);
}
示例2: CompareImages
static bool CompareImages(mitk::Image::Pointer mitkImage, cv::Mat openCVImage)
{
float equal = true;
if ((mitkImage->GetDimension(0)!=openCVImage.cols)||(mitkImage->GetDimension(1)!=openCVImage.rows))
{
equal = false;
}
for (unsigned int i=0; i<openCVImage.cols; i++)
{
for (unsigned int j=0; j<openCVImage.rows; j++)
{
mitk::Index3D currentIndex;
currentIndex[0] = i;
currentIndex[1] = j;
currentIndex[2] = 0;
float mitkImageValue = mitkImage->GetPixelValueByIndex(currentIndex);
float openCVImageValue = openCVImage.at<float>(j,i);
if (!mitk::Equal(mitkImageValue,openCVImageValue))
{
equal = false;
}
}
}
return equal;
}
示例3:
void mitk::SurfaceInterpolationController::SetCurrentInterpolationSession(mitk::Image::Pointer currentSegmentationImage)
{
if (currentSegmentationImage.GetPointer() == m_SelectedSegmentation)
return;
if (currentSegmentationImage.IsNull())
{
m_SelectedSegmentation = nullptr;
return;
}
m_SelectedSegmentation = currentSegmentationImage.GetPointer();
auto it = m_ListOfInterpolationSessions.find(currentSegmentationImage.GetPointer());
// If the session does not exist yet create a new ContourPositionPairList otherwise reinitialize the interpolation pipeline
if (it == m_ListOfInterpolationSessions.end())
{
ContourPositionInformationVec2D newList;
m_ListOfInterpolationSessions.insert(std::pair<mitk::Image*, ContourPositionInformationVec2D>(m_SelectedSegmentation, newList));
m_InterpolationResult = nullptr;
m_CurrentNumberOfReducedContours = 0;
itk::MemberCommand<SurfaceInterpolationController>::Pointer command = itk::MemberCommand<SurfaceInterpolationController>::New();
command->SetCallbackFunction(this, &SurfaceInterpolationController::OnSegmentationDeleted);
m_SegmentationObserverTags.insert( std::pair<mitk::Image*, unsigned long>( m_SelectedSegmentation, m_SelectedSegmentation->AddObserver( itk::DeleteEvent(), command ) ) );
}
this->ReinitializeInterpolation();
}
示例4: accessor
void mitk::MorphologicalOperations::FillHoles(mitk::Image::Pointer &image)
{
MITK_INFO << "Start FillHole...";
int timeSteps = static_cast<int>(image->GetTimeSteps());
if (timeSteps > 1)
{
mitk::ImageTimeSelector::Pointer timeSelector = mitk::ImageTimeSelector::New();
timeSelector->SetInput(image);
for (int t = 0; t < timeSteps; ++t)
{
MITK_INFO << " Processing time step " << t;
timeSelector->SetTimeNr(t);
timeSelector->Update();
mitk::Image::Pointer img3D = timeSelector->GetOutput();
img3D->DisconnectPipeline();
AccessByItk_1(img3D, itkFillHoles, img3D);
mitk::ImageReadAccessor accessor(img3D);
image->SetVolume(accessor.GetData(), t);
}
}
else
{
AccessByItk_1(image, itkFillHoles, image);
}
MITK_INFO << "Finished FillHole";
}
示例5: CompareImages
static bool CompareImages(mitk::Image::Pointer mitkImage, cv::Mat openCVImage)
{
float equal = true;
if (static_cast<int>(mitkImage->GetDimension(0)) != openCVImage.cols || static_cast<int>(mitkImage->GetDimension(1)) != openCVImage.rows)
{
equal = false;
}
mitk::ImagePixelReadAccessor<float,2> imageAcces(mitkImage, mitkImage->GetSliceData(0));
for(int i=0; i<openCVImage.cols; i++)
{
for(int j=0; j<openCVImage.rows; j++)
{
itk::Index<2> currentIndex;
currentIndex[0] = i;
currentIndex[1] = j;
float mitkImageValue = imageAcces.GetPixelByIndex(currentIndex);
float openCVImageValue = openCVImage.at<float>(j,i);
if (!mitk::Equal(mitkImageValue,openCVImageValue))
{
equal = false;
}
}
}
return equal;
}
示例6: inputReadAccessor
void mitk::USTelemedImageSource::GetNextRawImage( mitk::Image::Pointer& image)
{
if ( image.IsNull() ) { image = mitk::Image::New(); }
//get the actual resolution to check if it changed. We have to do this every time because the geometry takes a few frames to adapt
Usgfw2Lib::tagImageResolution resolutionInMetersActual;
m_ImageProperties->GetResolution(&resolutionInMetersActual, 0);
if (m_OldnXPelsPerUnit != resolutionInMetersActual.nXPelsPerUnit || m_OldnYPelsPerUnit != resolutionInMetersActual.nYPelsPerUnit)
{
//we can only update if the image exists and has a geometry
if (m_Image.IsNotNull() && m_Image->GetGeometry() != nullptr)
{
m_OldnXPelsPerUnit = resolutionInMetersActual.nXPelsPerUnit;
m_OldnYPelsPerUnit = resolutionInMetersActual.nYPelsPerUnit;
UpdateImageGeometry();
}
}
//now update image
if ( m_Image->IsInitialized() )
{
m_ImageMutex->Lock();
// copy contents of the given image into the member variable
image->Initialize(m_Image->GetPixelType(), m_Image->GetDimension(), m_Image->GetDimensions());
mitk::ImageReadAccessor inputReadAccessor(m_Image, m_Image->GetSliceData(0,0,0));
image->SetSlice(inputReadAccessor.GetData());
image->SetGeometry(m_Image->GetGeometry());
m_ImageMutex->Unlock();
}
}
示例7: AddColouredOverlay
/**
* @brief AddColouredOverlay - Overlays the rgbImage with an coloured overlay
*
* For all positions in overlayImage not zero, its value is multiplied the the colour value and added
* to the rgbImage.
*
* @param rgbImage - input rgbImage to which the coloured overlay is added
* @param overlayImage
* @param color
*/
void AddColouredOverlay(mitk::Image::Pointer rgbImage, mitk::Image::Pointer overlayImage, mitk::Color color)
{
unsigned int *dim = rgbImage->GetDimensions();
itk::Image<PixelType,3>::Pointer itkOverlayImage = itk::Image<PixelType,3>::New();
mitk::CastToItkImage(overlayImage.GetPointer(), itkOverlayImage);
mitk::ImagePixelWriteAccessor<RGBPixelType ,3> writeAcc(rgbImage);
itk::Index<3> idx;
itk::RGBPixel<PixelType> value;
unsigned short overlayVal=0;
// Fill rgb image with gray values
for (idx[2] =0; (unsigned int)idx[2] < dim[2]; idx[2]++)
{
for (idx[1] =0; (unsigned int)idx[1] < dim[1]; idx[1]++)
{
for (idx[0] =0; (unsigned int)idx[0] < dim[0]; idx[0]++)
{
overlayVal = 255*itkOverlayImage->GetPixel(idx);
value = writeAcc.GetPixelByIndex(idx);
value[0] = std::min( (int)(value[0] + overlayVal * color[0]),254*255);
value[1] = std::min((int)(value[1] + overlayVal * color[1]),254*255) ;
value[2] = std::min((int)(value[2] + overlayVal * color[2]),254*255);
writeAcc.SetPixelByIndex(idx, value);
}
}
}
}
示例8: StartSimulation
void StartSimulation(FiberfoxParameters<double> parameters, FiberBundle::Pointer fiberBundle, mitk::Image::Pointer refImage, string message)
{
itk::TractsToDWIImageFilter< short >::Pointer tractsToDwiFilter = itk::TractsToDWIImageFilter< short >::New();
tractsToDwiFilter->SetUseConstantRandSeed(true);
tractsToDwiFilter->SetParameters(parameters);
tractsToDwiFilter->SetFiberBundle(fiberBundle);
tractsToDwiFilter->Update();
mitk::Image::Pointer testImage = mitk::GrabItkImageMemory( tractsToDwiFilter->GetOutput() );
testImage->SetProperty( mitk::DiffusionPropertyHelper::GRADIENTCONTAINERPROPERTYNAME.c_str(), mitk::GradientDirectionsProperty::New( parameters.m_SignalGen.GetGradientDirections() ) );
testImage->SetProperty( mitk::DiffusionPropertyHelper::REFERENCEBVALUEPROPERTYNAME.c_str(), mitk::FloatProperty::New( parameters.m_SignalGen.m_Bvalue ) );
mitk::DiffusionPropertyHelper propertyHelper( testImage );
propertyHelper.InitializeImage();
if (refImage.IsNotNull())
{
if( static_cast<mitk::GradientDirectionsProperty*>( refImage->GetProperty(mitk::DiffusionPropertyHelper::GRADIENTCONTAINERPROPERTYNAME.c_str()).GetPointer() )->GetGradientDirectionsContainer().IsNotNull() )
{
ItkDwiType::Pointer itkTestImagePointer = ItkDwiType::New();
mitk::CastToItkImage(testImage, itkTestImagePointer);
ItkDwiType::Pointer itkRefImagePointer = ItkDwiType::New();
mitk::CastToItkImage(refImage, itkRefImagePointer);
bool cond = CompareDwi(itkTestImagePointer, itkRefImagePointer);
if (!cond)
{
MITK_INFO << "Saving test and rference image to " << mitk::IOUtil::GetTempPath();
mitk::IOUtil::SaveBaseData(testImage, mitk::IOUtil::GetTempPath()+"testImage.dwi");
mitk::IOUtil::SaveBaseData(refImage, mitk::IOUtil::GetTempPath()+"refImage.dwi");
}
MITK_TEST_CONDITION_REQUIRED(cond, message);
}
}
}
示例9: mitkThrow
void mitk::NonStaticArithmeticOperation::CallExecuteTwoImageFilter(mitk::Image::Pointer imageA, mitk::Image::Pointer imageB)
{
if (imageA->GetDimension() != imageB->GetDimension())
{
mitkThrow() << "Image have different dimensions. This is not supported by mitk::ArithmeticOperation";
}
switch (imageA->GetDimension())
{
case 1:
AccessTwoImagesFixedDimensionByItk(imageA, imageB, mitk::NonStaticArithmeticOperation::ExecuteTwoImageFilter, 1);
break;
case 2:
AccessTwoImagesFixedDimensionByItk(imageA, imageB, mitk::NonStaticArithmeticOperation::ExecuteTwoImageFilter, 2);
break;
case 3:
AccessTwoImagesFixedDimensionByItk(imageA, imageB, mitk::NonStaticArithmeticOperation::ExecuteTwoImageFilter, 3);
break;
case 4:
AccessTwoImagesFixedDimensionByItk(imageA, imageB, mitk::NonStaticArithmeticOperation::ExecuteTwoImageFilter, 4);
break;
default:
mitkThrow() << "Image Dimension of "<<imageA->GetDimension() << " is not supported";
break;
}
}
示例10: CompareImages
static bool CompareImages(mitk::Image::Pointer image1, mitk::Image::Pointer image2)
{
unsigned int dimX = image1->GetDimension(0);
unsigned int dimY = image1->GetDimension(1);
//make sure images have the same dimensions
if((dimX != image1->GetDimension(0)) || (dimY != image1->GetDimension(1)))
return false;
//compare all pixel values
for(unsigned int i = 0; i<dimX; i++)
{
for(unsigned int j = 0; j < dimY; j++)
{
mitk::Index3D idx;
idx[0] = i; idx[1] = j; idx[2] = 0;
if(!(mitk::Equal(image1->GetPixelValueByIndex(idx), image1->GetPixelValueByIndex(idx))))
{
return false;
}
}
}
//all pixels have identical values
return true;
}
示例11: Init
void Init()
{
im1 = mitk::ImageGenerator::GenerateRandomImage<double>(2,2,2,1,2,2,2,1,0);
im2 = mitk::ImageGenerator::GenerateRandomImage<double>(3,3,3,1,3,3,3,3,2);
im3 = mitk::ImageGenerator::GenerateRandomImage<double>(4,4,4,1,4,4,4,5,4);
im4 = mitk::ImageGenerator::GenerateRandomImage<double>(5,5,5,1,5,5,5,7,6);
dataCol1 = mitk::DataCollection::New();
dataCol2 = mitk::DataCollection::New();
dataCol1->AddData(im1.GetPointer(),"T1");
dataCol1->AddData(im2.GetPointer(),"T2");
dataCol2->AddData(im3.GetPointer(),"T1");
dataCol2->AddData(im4.GetPointer(),"T2");
col1 = mitk::DataCollection::New();
col1->SetName("GnaBla");
col1->AddData(dataCol1.GetPointer(), "0001");
col1->AddData(dataCol2.GetPointer(), "0002");
m_Collection = mitk::DataCollection::New();
m_Collection->SetName("DummyCollection");
m_Collection->AddData(col1.GetPointer(), "C1");
}
示例12: switch
Attributes::Attributes(mitk::Image::Pointer mitkImage)
{
log_trace(Log::New, this);
Pixel::ID pixelID;
Component::ID componentID;
unsigned int dimension;
log_info("pixelType: " << mitkImage->GetPixelType().GetPixelTypeAsString());
log_info("channels : " << mitkImage->GetPixelType().GetNumberOfComponents());
log_info("component: " << mitkImage->GetPixelType().GetComponentTypeAsString());
log_info("dimension: " << mitkImage->GetDimension());
switch (mitkImage->GetPixelType().GetPixelType())
{
case itk::ImageIOBase::SCALAR: pixelID = Pixel::ID::Scalar; break;
case itk::ImageIOBase::RGB: pixelID = Pixel::ID::Rgb; break;
case itk::ImageIOBase::RGBA: pixelID = Pixel::ID::Rgba; break;
default: pixelID = Pixel::ID::Scalar; break;
}
switch ((itk::ImageIOBase::IOComponentType) mitkImage->GetPixelType().GetComponentType())
{
case itk::ImageIOBase::UCHAR: componentID = Component::ID::UChar; break;
case itk::ImageIOBase::USHORT: componentID = Component::ID::UShort; break;
case itk::ImageIOBase::UINT: componentID = Component::ID::UInt; break;
case itk::ImageIOBase::CHAR: componentID = Component::ID::Char; break;
case itk::ImageIOBase::SHORT: componentID = Component::ID::Short; break;
case itk::ImageIOBase::INT: componentID = Component::ID::Int; break;
case itk::ImageIOBase::FLOAT: componentID = Component::ID::Float; break;
case itk::ImageIOBase::DOUBLE: componentID = Component::ID::Double; break;
default: componentID = Component::ID::Double; break;
}
if (mitkImage->GetPixelType().GetNumberOfComponents() == 1)
{
pixelID = Pixel::ID::Scalar;
}
if (mitkImage->GetPixelType().GetNumberOfComponents() == 3)
{
pixelID = Pixel::ID::Rgb;
}
if (mitkImage->GetPixelType().GetNumberOfComponents() == 4)
{
pixelID = Pixel::ID::Rgba;
}
dimension = mitkImage->GetDimension();
this->m_dimension = dimension;
this->m_pixelID = pixelID;
this->m_componentID = componentID;
}
示例13: Modified
void mitk::SurfaceInterpolationController::SetCurrentInterpolationSession(mitk::Image::Pointer currentSegmentationImage)
{
if (currentSegmentationImage.GetPointer() == m_SelectedSegmentation)
return;
m_ReduceFilter->Reset();
m_NormalsFilter->Reset();
m_InterpolateSurfaceFilter->Reset();
if (currentSegmentationImage.IsNull())
{
m_SelectedSegmentation = 0;
return;
}
ContourListMap::iterator it = m_ListOfInterpolationSessions.find(currentSegmentationImage.GetPointer());
m_SelectedSegmentation = currentSegmentationImage.GetPointer();
itk::ImageBase<3>::Pointer itkImage = itk::ImageBase<3>::New();
AccessFixedDimensionByItk_1( m_SelectedSegmentation, GetImageBase, 3, itkImage );
m_InterpolateSurfaceFilter->SetReferenceImage( itkImage.GetPointer() );
if (it == m_ListOfInterpolationSessions.end())
{
ContourPositionPairList newList;
m_ListOfInterpolationSessions.insert(std::pair<mitk::Image*, ContourPositionPairList>(m_SelectedSegmentation, newList));
m_InterpolationResult = 0;
m_CurrentNumberOfReducedContours = 0;
itk::MemberCommand<SurfaceInterpolationController>::Pointer command = itk::MemberCommand<SurfaceInterpolationController>::New();
command->SetCallbackFunction(this, &SurfaceInterpolationController::OnSegmentationDeleted);
m_SegmentationObserverTags.insert( std::pair<mitk::Image*, unsigned long>( m_SelectedSegmentation, m_SelectedSegmentation->AddObserver( itk::DeleteEvent(), command ) ) );
}
else
{
for (unsigned int i = 0; i < m_ListOfInterpolationSessions[m_SelectedSegmentation].size(); i++)
{
m_ReduceFilter->SetInput(i, m_ListOfInterpolationSessions[m_SelectedSegmentation].at(i).contour);
}
m_ReduceFilter->Update();
m_CurrentNumberOfReducedContours = m_ReduceFilter->GetNumberOfOutputs();
for (unsigned int i = 0; i < m_CurrentNumberOfReducedContours; i++)
{
m_NormalsFilter->SetInput(i, m_ReduceFilter->GetOutput(i));
m_InterpolateSurfaceFilter->SetInput(i, m_NormalsFilter->GetOutput(i));
}
}
Modified();
}
示例14: Paint
static void Paint(mitk::Image::Pointer image, itk::Index<3> index, unsigned int timeStep)
{
// As soon as the ImagePixelWriteAccessor object goes out of scope at the
// end of this function, the image will be unlocked again (RAII).
mitk::ImagePixelWriteAccessor<T> writeAccessor(image, image->GetVolumeData(timeStep));
writeAccessor.SetPixelByIndex(index, std::numeric_limits<T>::min());
// Don't forget to update the modified time stamp of the image. Otherwise,
// everything downstream wouldn't recognize that the image changed,
// including the rendering system.
image->Modified();
}
示例15: catch
/**
* @brief RemapIntoVectorImage Take a 3d+t image and reinterpret it as vector image
* @return vectoriamge
*/
mitk::DiffusionImageCreationFilter::VectorImageType::Pointer
mitk::DiffusionImageCreationFilter::RemapIntoVectorImage( mitk::Image::Pointer input)
{
typedef itk::Image<mitk::DiffusionPropertyHelper::DiffusionPixelType, 3> ImageVolumeType;
typedef itk::ComposeImageFilter< ImageVolumeType > ComposeFilterType;
ComposeFilterType::Pointer vec_composer = ComposeFilterType::New();
mitk::ImageTimeSelector::Pointer t_selector = mitk::ImageTimeSelector::New();
t_selector->SetInput( input );
for( unsigned int i=0; i< input->GetTimeSteps(); i++)
{
t_selector->SetTimeNr(i);
t_selector->Update();
ImageVolumeType::Pointer singleImageItk;
mitk::CastToItkImage( t_selector->GetOutput(), singleImageItk );
vec_composer->SetInput( i, singleImageItk );
}
try
{
vec_composer->Update();
}
catch( const itk::ExceptionObject& e)
{
MITK_ERROR << "Caught exception while updating compose filter: " << e.what();
}
mitk::DiffusionImageCreationFilter::VectorImageType::Pointer vector_image = vec_composer->GetOutput();
vector_image->GetPixelContainer()->ContainerManageMemoryOff();
return vector_image;
}