本文整理汇总了C++中imagetype::RegionType::IsInside方法的典型用法代码示例。如果您正苦于以下问题:C++ RegionType::IsInside方法的具体用法?C++ RegionType::IsInside怎么用?C++ RegionType::IsInside使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类imagetype::RegionType
的用法示例。
在下文中一共展示了RegionType::IsInside方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: internalGetSegmentationValues
//calculate segmentation values
bool CTImageTreeItem::internalGetSegmentationValues( SegmentationValues &values) const {
//get ITK image
ImageType::Pointer image = getITKImage();
if (image.IsNull())
return false;
//get buffered region of the image
ImageType::RegionType ctregion = image->GetBufferedRegion();
//define an iterator for the binary segment
typedef itk::ImageRegionConstIteratorWithIndex< BinaryImageType > BinaryIteratorType;
//get binary segment
BinaryImageTreeItem::ImageType::Pointer segment = values.m_segment->getITKImage();
if (segment.IsNull())
return false;
/* typedef itk::ImageFileWriter< ImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName( "test.dcm" );
writer->SetInput( image );
try
{
writer->Update();
}
catch( itk::ExceptionObject & excep )
{
std::cerr << "Exception catched !" << std::endl;
std::cerr << excep << std::endl;
}
*/
//create a binary iterator for the segment and its buffered region
BinaryIteratorType binIter( segment, segment->GetBufferedRegion() );
ImageType::PointType point;
//The Accumulators Framework is framework for performing incremental calculations
using namespace boost::accumulators;
//http://boost-sandbox.sourceforge.net/libs/accumulators/doc/html/accumulators/user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework
accumulator_set<double,features<tag::count, tag::min, tag::mean, tag::max, tag::variance> > acc;
//check selected accuracy
if (values.m_accuracy == SegmentationValues::SimpleAccuracy) {
ImageType::IndexType index;
//iterate over the pixel of the binary segment
for(binIter.GoToBegin(); !binIter.IsAtEnd(); ++binIter) {
//if actual value = 255
if (binIter.Value() == BinaryPixelOn) {
//transforms the index to a physical point in the binary segment
segment->TransformIndexToPhysicalPoint(binIter.GetIndex(),point);
//transform that point to an index of the CT image
image->TransformPhysicalPointToIndex(point, index);
//check if that index is inside the CT region
if (ctregion.IsInside(index)) {
//get the pixel value at the index
int t = image->GetPixel(index);
//check if pixel value != -2048
if (isRealHUvalue(t)) {
//accumulate pixel value
acc( t );
}
}
}
}
//check selected accuracy
} else if (values.m_accuracy == SegmentationValues::PreventDoubleSamplingAccuracy) {
ImageType::IndexType index;
//definition for a set of indices, which can be compared
typedef std::set< ImageType::IndexType, IndexCompareFunctor > IndexSetType;
IndexSetType indexSet;
//iterate over the pixel of the binary segment
for(binIter.GoToBegin(); !binIter.IsAtEnd(); ++binIter) {
//if actual value = 255
if (binIter.Value() == BinaryPixelOn) {
//transforms the index to a physical point in the binary segment
segment->TransformIndexToPhysicalPoint(binIter.GetIndex(),point);
//transform that point to an index of the CT image
image->TransformPhysicalPointToIndex(point, index);
//check if that index is inside the CT region
if (ctregion.IsInside(index)) {
std::pair<IndexSetType::iterator,IndexSetType::iterator> ret;
//
ret = indexSet.equal_range(index);
//If x does not match any key in the container, the range returned has a length of zero,
//with both iterators pointing to the nearest value greater than x, if any,
//or to set::end if x is greater than all the elements in the container.
if (ret.first == ret.second) {
indexSet.insert(ret.first, index);
//get the pixel value at the index
int t = image->GetPixel(index);
//check if pixel value != -2048
if (isRealHUvalue(t)) {
//accumulate pixel value
acc( t );
}
}
}
}
}
//.........这里部分代码省略.........