当前位置: 首页>>代码示例>>C++>>正文


C++ Pointer::GetLargestPossibleRegion方法代码示例

本文整理汇总了C++中image::Pointer::GetLargestPossibleRegion方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::GetLargestPossibleRegion方法的具体用法?C++ Pointer::GetLargestPossibleRegion怎么用?C++ Pointer::GetLargestPossibleRegion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在image::Pointer的用法示例。


在下文中一共展示了Pointer::GetLargestPossibleRegion方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:ybearzi,项目名称:skull_stripping,代码行数:29,代码来源:strip.cpp

示例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]);
	}
}
开发者ID:DanielGutmann,项目名称:millipede,代码行数:35,代码来源:main.cpp

示例3: get_mean

float get_mean(Image::Pointer im)
{
	ConstIterator it;
	it = ConstIterator(im, im->GetLargestPossibleRegion());
	
	float mean = 0, N=0;

	try
	{
		while(!it.IsAtEnd())
		{
			if(it.Get()!=0)
			{
				mean = N/(N+1)*mean + it.Get()/(N+1);
				++N;
			}
			++it;
		}
	}
	catch( itk::ExceptionObject & err)
	{
		std::cout<<"Error calculating mean, iterator error"<<std::endl;
		std::cout<<err<<std::endl;
	}

	return mean;
}
开发者ID:ybearzi,项目名称:skull_stripping,代码行数:27,代码来源:strip.cpp

示例4: binary_and

Image::Pointer binary_and(Image::Pointer input, ImageBinary::Pointer mask)
{
	Image::Pointer output = Image::New();
	Image::RegionType region = input->GetLargestPossibleRegion();
	output->SetRegions(region);

	try
	{
		output->Allocate();
	}
	catch(itk::ExceptionObject & err)
	{
		std::cout<<"Error in binary_and. Allocation failed"<<std::endl;
		std::cout<<err<<std::endl;
		return NULL;
	}

	ConstIteratorBinary iterator_mask(mask, mask->GetLargestPossibleRegion());
	Iterator iterator_input(input, input->GetLargestPossibleRegion());
	Iterator iterator_output(output, output->GetLargestPossibleRegion());

	// all images should be the same size
	
	try
	{
		while(!iterator_input.IsAtEnd())
		{
			if(iterator_mask.Get() == 0)
				iterator_output.Set(0);
			else
				iterator_output.Set(iterator_input.Get());
			++iterator_input; ++iterator_mask; ++iterator_output;
		}
	}
	catch(itk::ExceptionObject & err)
	{
		std::cout<<"Iterator error"<<std::endl;
		std::cout<<err<<std::endl;
	}
	
	return output;
}
开发者ID:ybearzi,项目名称:skull_stripping,代码行数:42,代码来源:strip.cpp

示例5: get_volume

unsigned int get_volume(Image::Pointer im)
{
	ConstIterator it;
	it = ConstIterator(im, im->GetLargestPossibleRegion());
	
	unsigned int volume;

	try
	{
		while(!it.IsAtEnd())
		{
			if(it.Get()!=0)
				++volume;
			++it;
		}
	}
	catch( itk::ExceptionObject & err)
	{
		std::cout<<"Error calculating volume, iterator error"<<std::endl;
		std::cout<<err<<std::endl;
	}

	return volume;
}
开发者ID:ybearzi,项目名称:skull_stripping,代码行数:24,代码来源:strip.cpp

示例6: get_max

unsigned int get_max(Image::Pointer im)
{
	ConstIterator it;
	it = ConstIterator(im, im->GetLargestPossibleRegion());
	
	unsigned int max = 0;

	try
	{
		while(!it.IsAtEnd())
		{
			if(it.Get()>max)
				max = it.Get();
			++it;
		}
	}
	catch( itk::ExceptionObject & err)
	{
		std::cout<<"Error calculating maximum, iterator error"<<std::endl;
		std::cout<<err<<std::endl;
	}

	return max;
}
开发者ID:ybearzi,项目名称:skull_stripping,代码行数:24,代码来源:strip.cpp

示例7: ConvertStreamToNrrdFormat

  void ToFNrrdImageWriter::ConvertStreamToNrrdFormat( std::string fileName )
  {
    int CaptureWidth = 0;
    int CaptureHeight = 0;
    int PixelNumber = 0;
    int ImageSizeInBytes = 0;
    if (fileName==this->m_RGBImageFileName)
    {
        CaptureWidth = this->m_RGBCaptureWidth;
        CaptureHeight = this->m_RGBCaptureHeight;
        PixelNumber = this->m_RGBPixelNumber;
        ImageSizeInBytes = this->m_RGBImageSizeInBytes;
    } else
    {
        CaptureWidth = this->m_ToFCaptureWidth;
        CaptureHeight = this->m_ToFCaptureHeight;
        PixelNumber = this->m_ToFPixelNumber;
        ImageSizeInBytes = this->m_ToFImageSizeInBytes;
    }
    Image::Pointer imageTemplate = Image::New();
    int dimension ;
    unsigned int* dimensions;
    if(m_ToFImageType == ToFImageType2DPlusT)
    {
      dimension = 4;
      dimensions = new unsigned int[dimension];
      dimensions[0] = CaptureWidth;
      dimensions[1] = CaptureHeight;
      dimensions[2] = 1;
      dimensions[3] = this->m_NumOfFrames;
    }
    else if( m_ToFImageType == ToFImageType3D)
    {
      dimension = 3;
      dimensions = new unsigned int[dimension];
      dimensions[0] = CaptureWidth;
      dimensions[1] = CaptureHeight;
      dimensions[2] = this->m_NumOfFrames;
    }
    else
    {
      throw std::logic_error("No image type set, please choose between 2D+t and 3D!");
    }
    float* floatData;
    unsigned char* rgbData;
    if (fileName==this->m_RGBImageFileName)
    {
      rgbData = new unsigned char[PixelNumber*3];
      for(int i=0; i<PixelNumber*3; i++)
      {
        rgbData[i] = i + 0.0;
      }
      mitk::PixelType RGBType = MakePixelType<unsigned char, itk::RGBPixel<unsigned char>, 3>();
      imageTemplate->Initialize( RGBType,dimension, dimensions, 1);
      imageTemplate->SetSlice(rgbData, 0, 0, 0);
    }
    else
    {
      floatData = new float[PixelNumber];
      for(int i=0; i<PixelNumber; i++)
      {
        floatData[i] = i + 0.0;
      }
      mitk::PixelType FloatType = MakeScalarPixelType<float>();
      imageTemplate->Initialize( FloatType,dimension, dimensions, 1);
      imageTemplate->SetSlice(floatData, 0, 0, 0);
    }

    itk::NrrdImageIO::Pointer nrrdWriter = itk::NrrdImageIO::New();
    nrrdWriter->SetNumberOfDimensions(dimension);
    nrrdWriter->SetPixelType( imageTemplate->GetPixelType().GetPixelType());
    nrrdWriter->SetComponentType( (itk::ImageIOBase::IOComponentType) imageTemplate->GetPixelType().GetComponentType());
    if(imageTemplate->GetPixelType().GetNumberOfComponents() > 1)
    {
      nrrdWriter->SetNumberOfComponents(imageTemplate->GetPixelType().GetNumberOfComponents());
    }

    itk::ImageIORegion ioRegion( dimension );
    mitk::Vector3D spacing = imageTemplate->GetGeometry()->GetSpacing();
    mitk::Point3D origin = imageTemplate->GetGeometry()->GetOrigin();

    for(unsigned int i = 0; i < dimension; i++)
    {
      nrrdWriter->SetDimensions(i,dimensions[i]);
      nrrdWriter->SetSpacing(i,spacing[i]);
      nrrdWriter->SetOrigin(i,origin[i]);

      mitk::Vector3D direction;
      direction.Set_vnl_vector(imageTemplate->GetGeometry()->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix().get_column(i));
      vnl_vector< double > axisDirection(dimension);

      for(unsigned int j = 0; j < dimension; j++)
      {
        axisDirection[j] = direction[j]/spacing[i];
      }
      nrrdWriter->SetDirection( i, axisDirection );

      ioRegion.SetSize(i, imageTemplate->GetLargestPossibleRegion().GetSize(i) );
      ioRegion.SetIndex(i, imageTemplate->GetLargestPossibleRegion().GetIndex(i) );
    }
//.........这里部分代码省略.........
开发者ID:151706061,项目名称:MITK,代码行数:101,代码来源:mitkToFNrrdImageWriter.cpp


注:本文中的image::Pointer::GetLargestPossibleRegion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。