本文整理汇总了C++中imagetype::RegionType::Crop方法的典型用法代码示例。如果您正苦于以下问题:C++ RegionType::Crop方法的具体用法?C++ RegionType::Crop怎么用?C++ RegionType::Crop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类imagetype::RegionType
的用法示例。
在下文中一共展示了RegionType::Crop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: inIt
void mitk::AutoCropImageFilter::ComputeNewImageBounds()
{
mitk::Image::ConstPointer inputMitk = this->GetInput();
if (m_OverrideCroppingRegion)
{
for (unsigned int i=0; i<3; ++i)
{
m_RegionIndex[i] = m_CroppingRegion.GetIndex()[i];
m_RegionSize[i] = m_CroppingRegion.GetSize()[i];
if (m_RegionIndex[i] >= inputMitk->GetDimension(i))
{
itkExceptionMacro("Cropping index is not inside the image. "
<< std::endl << "Index:"
<< std::endl << m_CroppingRegion.GetIndex()
<< std::endl << "Size:"
<< std::endl << m_CroppingRegion.GetSize());
}
if (m_RegionIndex[i] + m_RegionSize[i] >= inputMitk->GetDimension(i))
{
m_RegionSize[i] = inputMitk->GetDimension(i) - m_RegionIndex[i];
}
}
for (unsigned int i=0; i<3; ++i)
{
m_RegionIndex[i] = m_CroppingRegion.GetIndex()[i];
m_RegionSize[i] = m_CroppingRegion.GetSize()[i];
}
}
else
{
// Check if a 3D or 4D image is present
unsigned int timeSteps = 1;
if (inputMitk->GetDimension() == 4 )
timeSteps = inputMitk->GetDimension(3);
ImageType::IndexType minima,maxima;
if (inputMitk->GetDimension() == 4)
{
// initialize with time step 0
m_TimeSelector = mitk::ImageTimeSelector::New();
m_TimeSelector->SetInput( inputMitk );
m_TimeSelector->SetTimeNr( 0 );
m_TimeSelector->UpdateLargestPossibleRegion();
inputMitk = m_TimeSelector->GetOutput();
}
ImagePointer inputItk = ImageType::New();
mitk::CastToItkImage( inputMitk , inputItk );
// it is assumed that all volumes in a time series have the same 3D dimensions
ImageType::RegionType origRegion = inputItk->GetLargestPossibleRegion();
// Initialize min and max on the first (or only) time step
maxima = inputItk->GetLargestPossibleRegion().GetIndex();
minima[0] = inputItk->GetLargestPossibleRegion().GetSize()[0];
minima[1] = inputItk->GetLargestPossibleRegion().GetSize()[1];
minima[2] = inputItk->GetLargestPossibleRegion().GetSize()[2];
typedef itk::ImageRegionConstIterator< ImageType > ConstIteratorType;
for(unsigned int idx = 0; idx < timeSteps; ++idx)
{
// if 4D image, update time step and itk image
if( idx > 0)
{
m_TimeSelector->SetTimeNr( idx );
m_TimeSelector->UpdateLargestPossibleRegion();
inputMitk = m_TimeSelector->GetOutput();
mitk::CastToItkImage( inputMitk , inputItk );
}
ConstIteratorType inIt( inputItk, origRegion );
for ( inIt.GoToBegin(); !inIt.IsAtEnd(); ++inIt)
{
float pix_val = inIt.Get();
if ( fabs(pix_val - m_BackgroundValue) > mitk::eps )
{
for (int i=0; i < 3; i++)
{
minima[i] = vnl_math_min((int)minima[i],(int)(inIt.GetIndex()[i]));
maxima[i] = vnl_math_max((int)maxima[i],(int)(inIt.GetIndex()[i]));
}
}
}
}
typedef ImageType::RegionType::SizeType::SizeValueType SizeValueType;
m_RegionSize[0] = (SizeValueType)(m_MarginFactor * (maxima[0] - minima[0] + 1 ));
m_RegionSize[1] = (SizeValueType)(m_MarginFactor * (maxima[1] - minima[1] + 1 ));
m_RegionSize[2] = (SizeValueType)(m_MarginFactor * (maxima[2] - minima[2] + 1 ));
m_RegionIndex = minima;
m_RegionIndex[0] -= (m_RegionSize[0] - maxima[0] + minima[0] - 1 )/2;
//.........这里部分代码省略.........