本文整理汇总了C++中mitk::image::Pointer::Clone方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::Clone方法的具体用法?C++ Pointer::Clone怎么用?C++ Pointer::Clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mitk::image::Pointer
的用法示例。
在下文中一共展示了Pointer::Clone方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadMitkProjectImageAndMask
void ReadMitkProjectImageAndMask(std::string input_file, mitk::Image::Pointer & raw_image, mitk::Image::Pointer & class_mask, mitk::Image::Pointer & brain_mask)
{
auto so = mitk::IOUtil::Load(input_file);
std::map<uint, uint> map;
mitk::CLUtil::CountVoxel(dynamic_cast<mitk::Image *>(so[1].GetPointer()), map);
raw_image = map.size() <= 7 ? dynamic_cast<mitk::Image *>(so[0].GetPointer()) : dynamic_cast<mitk::Image *>(so[1].GetPointer());
class_mask = map.size() <= 7 ? dynamic_cast<mitk::Image *>(so[1].GetPointer()) : dynamic_cast<mitk::Image *>(so[0].GetPointer());
std::map<uint, uint> merge_instructions;// = {{0,0},{1,1},{2,1},{3,1},{4,2},{5,3},{6,3}};
merge_instructions[0] = 0;
merge_instructions[1] = 1;
merge_instructions[2] = 1;
merge_instructions[3] = 1;
merge_instructions[4] = 2;
merge_instructions[5] = 3;
merge_instructions[6] = 3;
mitk::CLUtil::MergeLabels(class_mask, merge_instructions);
brain_mask = class_mask->Clone();
//merge_instructions = {{0,0},{1,1},{2,1},{3,1},{4,1},{5,1},{6,1}};
merge_instructions[0] = 0;
merge_instructions[1] = 1;
merge_instructions[2] = 1;
merge_instructions[3] = 1;
merge_instructions[4] = 1;
merge_instructions[5] = 1;
merge_instructions[6] = 1;
mitk::CLUtil::MergeLabels(brain_mask, merge_instructions);
}
示例2: ConvertIplImageForthAndBack
void ConvertIplImageForthAndBack(mitk::Image::Pointer inputForIpl, std::string imageFileName)
{
// now we convert it to OpenCV IplImage
mitk::ImageToOpenCVImageFilter::Pointer toOCvConverter = mitk::ImageToOpenCVImageFilter::New();
toOCvConverter->SetImage(inputForIpl);
IplImage* iplTestImage = toOCvConverter->GetOpenCVImage();
MITK_TEST_CONDITION_REQUIRED( iplTestImage != NULL, "Conversion to OpenCv IplImage successful!");
mitk::OpenCVToMitkImageFilter::Pointer toMitkConverter = mitk::OpenCVToMitkImageFilter::New();
toMitkConverter->SetOpenCVImage(iplTestImage);
toMitkConverter->Update();
// initialize the image with the input image, since we want to test equality and OpenCV does not feature geometries and spacing
mitk::Image::Pointer result = inputForIpl->Clone();
mitk::ImageReadAccessor resultAcc(toMitkConverter->GetOutput(), toMitkConverter->GetOutput()->GetSliceData());
result->SetImportSlice(const_cast<void*>(resultAcc.GetData()));
if( result->GetPixelType().GetNumberOfComponents() == 1 )
{
MITK_TEST_EQUAL( result, inputForIpl, "Testing equality of input and output image of IplImage conversion for " << imageFileName );
}
else if( result->GetPixelType().GetNumberOfComponents() == 3 )
{
MITK_TEST_EQUAL( result, inputForIpl, "Testing equality of input and output image of cv::Mat conversion for " << imageFileName );
}
else
{
MITK_WARN << "Unhandled number of components used to test equality, please enhance test!";
}
}
示例3: Initialize
void QmitkImageStatisticsCalculationThread::Initialize( mitk::Image::Pointer image, mitk::Image::Pointer binaryImage, mitk::PlanarFigure::Pointer planarFig )
{
// reset old values
if( this->m_StatisticsImage.IsNotNull() )
this->m_StatisticsImage = 0;
if( this->m_BinaryMask.IsNotNull() )
this->m_BinaryMask = 0;
if( this->m_PlanarFigureMask.IsNotNull())
this->m_PlanarFigureMask = 0;
// set new values if passed in
if(image.IsNotNull())
this->m_StatisticsImage = image->Clone();
if(binaryImage.IsNotNull())
this->m_BinaryMask = binaryImage->Clone();
if(planarFig.IsNotNull())
this->m_PlanarFigureMask = planarFig->Clone();
}
示例4: Initialize
void QmitkImageStatisticsCalculationThread::Initialize( mitk::Image::Pointer image, mitk::Image::Pointer binaryImage, mitk::PlanarFigure::Pointer planarFig )
{
// reset old values
if( this->m_StatisticsImage.IsNotNull() )
this->m_StatisticsImage = 0;
if( this->m_BinaryMask.IsNotNull() )
this->m_BinaryMask = 0;
if( this->m_PlanarFigureMask.IsNotNull())
this->m_PlanarFigureMask = 0;
// set new values if passed in
if(image.IsNotNull())
this->m_StatisticsImage = image->Clone();
if(binaryImage.IsNotNull())
this->m_BinaryMask = binaryImage->Clone();
if(planarFig.IsNotNull())
this->m_PlanarFigureMask = dynamic_cast<mitk::PlanarFigure*>(planarFig.GetPointer()); // once clone methods for planar figures are implemented, copy the data here!
}
示例5: ConvertCVMatForthAndBack
void ConvertCVMatForthAndBack(mitk::Image::Pointer inputForCVMat, std::string imageFileName)
{
// now we convert it to OpenCV IplImage
mitk::ImageToOpenCVImageFilter::Pointer toOCvConverter = mitk::ImageToOpenCVImageFilter::New();
toOCvConverter->SetImage(inputForCVMat);
cv::Mat cvmatTestImage = toOCvConverter->GetOpenCVMat();
MITK_TEST_CONDITION_REQUIRED( !cvmatTestImage.empty(), "Conversion to cv::Mat successful!");
mitk::OpenCVToMitkImageFilter::Pointer toMitkConverter = mitk::OpenCVToMitkImageFilter::New();
toMitkConverter->SetOpenCVMat(cvmatTestImage);
toMitkConverter->Update();
// initialize the image with the input image, since we want to test equality and OpenCV does not feature geometries and spacing
mitk::Image::Pointer result = inputForCVMat->Clone();
mitk::ImageReadAccessor resultAcc(toMitkConverter->GetOutput(), toMitkConverter->GetOutput()->GetSliceData());
result->SetImportSlice(const_cast<void*>(resultAcc.GetData()));
if( result->GetPixelType().GetNumberOfComponents() == 1 )
{
MITK_TEST_EQUAL( result, inputForCVMat, "Testing equality of input and output image of cv::Mat conversion for " << imageFileName );
}
else if( result->GetPixelType().GetNumberOfComponents() == 3 )
{
MITK_TEST_EQUAL( result, inputForCVMat, "Testing equality of input and output image of cv::Mat conversion for " << imageFileName );
}
else
{
MITK_WARN << "Unhandled number of components used to test equality, please enhance test!";
}
// change OpenCV image to test if the filter gets updated
cv::Mat changedcvmatTestImage = cvmatTestImage.clone();
changedcvmatTestImage.at<char>(0,0) = cvmatTestImage.at<char>(0,0) != 0 ? 0 : 1;
toMitkConverter->SetOpenCVMat(changedcvmatTestImage);
toMitkConverter->Update();
MITK_TEST_NOT_EQUAL(toMitkConverter->GetOutput(), inputForCVMat, "Converted image must not be the same as before.");
}