本文整理汇总了C++中contourmodel::Pointer::GetNumberOfVertices方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::GetNumberOfVertices方法的具体用法?C++ Pointer::GetNumberOfVertices怎么用?C++ Pointer::GetNumberOfVertices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类contourmodel::Pointer
的用法示例。
在下文中一共展示了Pointer::GetNumberOfVertices方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: documentation
bool mitk::CorrectorAlgorithm::ImprovedHeimannCorrectionAlgorithm(itk::Image< ipMITKSegmentationTYPE, 2 >::Pointer pic)
{
/*!
Some documentation (not by the original author)
TobiasHeimannCorrectionAlgorithm will be called, when the user has finished drawing a freehand line.
There should be different results, depending on the line's properties:
1. Without any prior segmentation, the start point and the end point of the drawn line will be
connected to a contour and the area enclosed by the contour will be marked as segmentation.
2. When the whole line is inside a segmentation, start and end point will be connected to
a contour and the area of this contour will be subtracted from the segmentation.
3. When the line starts inside a segmentation and ends outside with only a single
transition from segmentation to no-segmentation, nothing will happen.
4. When there are multiple transitions between inside-segmentation and
outside-segmentation, the line will be divided in so called segments. Each segment is
either fully inside or fully outside a segmentation. When it is inside a segmentation, its
enclosed area will be subtracted from the segmentation. When the segment is outside a
segmentation, its enclosed area it will be added to the segmentation.
The algorithm is described in full length in Tobias Heimann's diploma thesis
(MBI Technical Report 145, p. 37 - 40).
*/
ContourModel::Pointer projectedContour = mitk::ContourModelUtils::ProjectContourTo2DSlice( m_WorkingImage, m_Contour, true, false );
bool firstPointIsFillingColor = false;
if (projectedContour.IsNull() ||
projectedContour->GetNumberOfVertices() < 2 )
{
return false;
}
// Read the first point of the contour
ContourModel::VertexIterator contourIter = projectedContour->Begin();
if (contourIter == projectedContour->End())
return false;
itk::Index<2> previousIndex;
previousIndex[0] = (*contourIter)->Coordinates[0];
previousIndex[1] = (*contourIter)->Coordinates[1];
++contourIter;
int currentColor = ( pic->GetPixel(previousIndex) == m_FillColor);
firstPointIsFillingColor = currentColor;
TSegData currentSegment;
int countOfSegments = 1;
bool firstSegment = true;
ContourModel::VertexIterator contourEnd = projectedContour->End();
for (; contourIter != contourEnd; ++contourIter)
{
// Get current point
itk::Index<2> currentIndex;
currentIndex[0] = (*contourIter)->Coordinates[0] +0.5;
currentIndex[1] = (*contourIter)->Coordinates[1] +0.5;
// Calculate length and slope
double slopeX = currentIndex[0] - previousIndex[0];
double slopeY = currentIndex[1] - previousIndex[1];
double length = std::sqrt(slopeX * slopeX + slopeY * slopeY);
double deltaX = slopeX / length;
double deltaY = slopeY / length;
for (double i = 0; i <= length && length > 0; i+=1)
{
itk::Index<2> temporaryIndex;
temporaryIndex[0] = previousIndex[0] + deltaX * i;
temporaryIndex[1] = previousIndex[1] + deltaY * i;
if ( ! pic->GetLargestPossibleRegion().IsInside(temporaryIndex))
continue;
if ( (pic->GetPixel(temporaryIndex) == m_FillColor) != currentColor)
{
currentSegment.points.push_back(temporaryIndex);
if ( ! firstSegment)
{
ModifySegment( currentSegment, pic);
} else
{
firstSegment = false;
}
currentSegment = TSegData();
++countOfSegments;
currentColor = (pic->GetPixel(temporaryIndex) == m_FillColor);
}
currentSegment.points.push_back(temporaryIndex);
}
previousIndex = currentIndex;
}
// Check if only on Segment
if (firstSegment && currentSegment.points.size() > 0)
{
ContourModel::Pointer projectedContour = mitk::ContourModelUtils::ProjectContourTo2DSlice( m_WorkingImage, m_Contour, true, false );
projectedContour->Close();
//.........这里部分代码省略.........