本文整理汇总了C++中NodeType::SetValue方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeType::SetValue方法的具体用法?C++ NodeType::SetValue怎么用?C++ NodeType::SetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeType
的用法示例。
在下文中一共展示了NodeType::SetValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void mitk::FastMarchingTool3D::OnAddPoint()
{
// Add a new seed point for FastMarching algorithm
mitk::Point3D clickInIndex;
m_ReferenceImage->GetGeometry()->WorldToIndex(m_SeedsAsPointSet->GetPoint(m_SeedsAsPointSet->GetSize()-1),
clickInIndex);
itk::Index<3> seedPosition;
seedPosition[0] = clickInIndex[0];
seedPosition[1] = clickInIndex[1];
seedPosition[2] = clickInIndex[2];
NodeType node;
const double seedValue = 0.0;
node.SetValue( seedValue );
node.SetIndex( seedPosition );
this->m_SeedContainer->InsertElement(this->m_SeedContainer->Size(), node);
m_FastMarchingFilter->Modified();
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
m_NeedUpdate = true;
this->Update();
}
示例2:
bool mitk::FastMarchingTool::OnAddPoint( StateMachineAction*, InteractionEvent* interactionEvent )
{
if ( SegTool2D::CanHandleEvent(interactionEvent) < 1.0 )
return false;
// Add a new seed point for FastMarching algorithm
mitk::InteractionPositionEvent* positionEvent = dynamic_cast<mitk::InteractionPositionEvent*>( interactionEvent );
//const PositionEvent* p = dynamic_cast<const PositionEvent*>(stateEvent->GetEvent());
if ( positionEvent == NULL ) return false;
if ( m_PositionEvent.IsNotNull() )
m_PositionEvent = NULL;
m_PositionEvent = InteractionPositionEvent::New( positionEvent->GetSender(),
positionEvent->GetPointerPositionOnScreen(),
positionEvent->GetPositionInWorld() );
//if click was on another renderwindow or slice then reset pipeline and preview
if( (m_LastEventSender != m_PositionEvent->GetSender()) || (m_LastEventSlice != m_PositionEvent->GetSender()->GetSlice()) )
{
this->BuildITKPipeline();
this->ClearSeeds();
}
m_LastEventSender = m_PositionEvent->GetSender();
m_LastEventSlice = m_LastEventSender->GetSlice();
mitk::Point3D clickInIndex;
m_ReferenceImageSlice->GetGeometry()->WorldToIndex(m_PositionEvent->GetPositionInWorld(), clickInIndex);
itk::Index<2> seedPosition;
seedPosition[0] = clickInIndex[0];
seedPosition[1] = clickInIndex[1];
NodeType node;
const double seedValue = 0.0;
node.SetValue( seedValue );
node.SetIndex( seedPosition );
this->m_SeedContainer->InsertElement(this->m_SeedContainer->Size(), node);
m_FastMarchingFilter->Modified();
m_SeedsAsPointSet->InsertPoint(m_SeedsAsPointSet->GetSize(), m_PositionEvent->GetPositionInWorld());
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
m_NeedUpdate = true;
this->Update();
m_ReadyMessage.Send();
return true;
}
示例3: fastMarchingImageFilterITK
void FastMarchingImageFilterITK::fastMarchingImageFilterITK() {
if (!enableProcessing_.get()) {
outport1_.setData(inport1_.getData(), false);
return;
}
//typedefs images
typedef itk::Image<T, 3> InputImageType;
//input image p1
typename InputImageType::Pointer p1 = voreenToITK<T>(inport1_.getData());
typedef itk::FastMarchingImageFilter< InputImageType, InputImageType > FastMarchingFilterType;
typename FastMarchingFilterType::Pointer fastMarching = FastMarchingFilterType::New();
typedef typename FastMarchingFilterType::NodeContainer NodeContainer;
typedef typename FastMarchingFilterType::NodeType NodeType;
typename NodeContainer::Pointer seeds = NodeContainer::New();
if (seedPointPort_.hasChanged()) {
const PointListGeometry<tgt::vec3>* pointList = dynamic_cast< const PointListGeometry<tgt::vec3>* >(seedPointPort_.getData());
if (pointList) {
seedPoints = pointList->getData();
if (!seedPoints.empty()) {
numSeedPoint_.setMinValue(1);
numSeedPoint_.setMaxValue(seedPoints.size());
numSeedPoint_.set(seedPoints.size());
}
else {
numSeedPoint_.setMinValue(0);
numSeedPoint_.setMaxValue(0);
numSeedPoint_.set(0);
}
}
}
if(!seedPoints.empty()) {
seedPoint_.set(seedPoints[numSeedPoint_.get()-1]);
}
else {
seedPoint_.set(tgt::vec3 (1));
}
typename InputImageType::IndexType seedPosition;
seedPosition[0] = seedPoint_.get().x;
seedPosition[1] = seedPoint_.get().y;
seedPosition[2] = seedPoint_.get().z;
const double initialDistance = initialDistance_.get();
NodeType node;
const double seedValue = - initialDistance;
node.SetValue( seedValue);
node.SetIndex (seedPosition);
seeds->Initialize();
seeds->InsertElement( 0, node);
fastMarching->SetTrialPoints( seeds );
fastMarching->SetSpeedConstant( 1.0f );
fastMarching->SetStoppingValue( stoptime_.get() );
fastMarching->SetInput(p1);
observe(fastMarching.GetPointer());
try
{
fastMarching->Update();
}
catch (itk::ExceptionObject &e)
{
LERROR(e);
}
Volume* outputVolume1 = 0;
outputVolume1 = ITKToVoreenCopy<T>(fastMarching->GetOutput());
if (outputVolume1) {
transferTransformation(inport1_.getData(), outputVolume1);
outport1_.setData(outputVolume1);
}
else
outport1_.setData(0);
}
示例4: main
//.........这里部分代码省略.........
SigmoidFilterType;
SigmoidFilterType::Pointer sigmoid = SigmoidFilterType::New();
sigmoid->SetOutputMinimum(0.0);
sigmoid->SetOutputMaximum(1.0);
sigmoid->SetAlpha( (K2 - K1)/6 );
sigmoid->SetBeta( (K1 + K2)/2 );
sigmoid->SetInput( gradientMagnitude->GetOutput() );
////////////////////////////////////////////////
// 5) Segmentation with geodesic active contour
typedef itk::FastMarchingImageFilter< InputImageType, InputImageType >
FastMarchingFilterType;
FastMarchingFilterType::Pointer fastMarching = FastMarchingFilterType::New();
typedef itk::GeodesicActiveContourLevelSetImageFilter<
InputImageType, InputImageType > GeodesicActiveContourFilterType;
GeodesicActiveContourFilterType::Pointer geodesicActiveContour =
GeodesicActiveContourFilterType::New();
const double propagation = atof( argv[11] );
const double curvature = atof( argv[12] );
const double advection = atof( argv[13] );
const double iterations = atoi( argv[14] );
geodesicActiveContour->SetPropagationScaling( propagation );
geodesicActiveContour->SetCurvatureScaling( curvature );
geodesicActiveContour->SetAdvectionScaling( advection );
geodesicActiveContour->SetMaximumRMSError(0.01);
geodesicActiveContour->SetNumberOfIterations( iterations );
geodesicActiveContour->SetInput( fastMarching->GetOutput() );
geodesicActiveContour->SetFeatureImage( sigmoid->GetOutput() );
////////////////////////////////////////////////
// 6) Binary thresholding
typedef itk::BinaryThresholdImageFilter< InputImageType, OutputImageType >
ThresholdingFilterType;
ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New();
thresholder->SetLowerThreshold(-1000.0);
thresholder->SetUpperThreshold(0.0);
thresholder->SetOutsideValue(0);
thresholder->SetInsideValue(255);
thresholder->SetInput( geodesicActiveContour->GetOutput() );
////////////////////////////////////////////////
// 7) Finish setting up fast marching
typedef FastMarchingFilterType::NodeContainer NodeContainer;
typedef FastMarchingFilterType::NodeType NodeType;
NodeContainer::Pointer seeds = NodeContainer::New();
InputImageType::IndexType seedPosition;
seedPosition[0] = atoi( argv[4] );
seedPosition[1] = atoi( argv[5] );
seedPosition[2] = atoi( argv[6] );
const double initialDistance = atof( argv[7] );
const double seedValue = -initialDistance;
NodeType node;
node.SetValue( seedValue );
node.SetIndex( seedPosition );
seeds->Initialize();
seeds->InsertElement(0, node);
fastMarching->SetTrialPoints( seeds );
fastMarching->SetSpeedConstant(1.0);
fastMarching->SetOutputSize( reader->GetOutput()->GetBufferedRegion().GetSize() );
fastMarching->SetOutputRegion( reader->GetOutput()->GetBufferedRegion() );
fastMarching->SetOutputSpacing( reader->GetOutput()->GetSpacing() );
fastMarching->SetOutputOrigin( reader->GetOutput()->GetOrigin() );
////////////////////////////////////////////////
// 7) Write output image
typedef itk::ImageFileWriter< OutputImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
std::string writepath( argv[1] );
writepath.append( argv[3] );
writer->SetFileName( writepath );
writer->SetInput( thresholder->GetOutput() );
try {
writer->Update();
}
catch( itk::ExceptionObject &excep ) {
std::cerr << "Exception caught!" << std::endl;
std::cerr << excep << std::endl;
return EXIT_FAILURE;
}
// The following writer is used to save the output of the sigmoid mapping
typedef itk::ImageFileWriter< InputImageType > InternalWriterType;
InternalWriterType::Pointer speedWriter = InternalWriterType::New();
speedWriter->SetInput( sigmoid->GetOutput() );
std::string sigmoidpath( argv[1] );
speedWriter->SetFileName( sigmoidpath.append("SigmoidForGeodesic.mha"));
speedWriter->Update();
return 0;
}
示例5: Execute
//.........这里部分代码省略.........
gradientMagnitude->SetSigma( sigma );
sigmoid->SetAlpha( alpha );
sigmoid->SetBeta( beta );
string line;
int x;
int y;
if (myfile.is_open())
{
getline (myfile,line);
string cmd = line;
string arg;
string::size_type pos = cmd.find(' ');
if(cmd.npos != pos) {
arg = cmd.substr(pos + 1);
cmd = cmd.substr(0, pos);
}
x = atoi(cmd.c_str());
y = atoi(arg.c_str());
}
typedef FastMarchingFilterType::NodeContainer NodeContainer;
typedef FastMarchingFilterType::NodeType NodeType;
NodeContainer::Pointer seeds = NodeContainer::New();
InternalImageType::IndexType seedPosition;
seedPosition.SetElement(0,x);
seedPosition.SetElement(1,y);
//seedPosition.SetElement(2,(int)z);
cout<<"X, Y = "<<x<<" "<<y<<endl;
NodeType node;
const double seedValue = - distance;
node.SetValue( seedValue );
node.SetIndex( seedPosition );
seeds->Initialize();
seeds->InsertElement( 0, node );
fastMarching->SetTrialPoints( seeds );
fastMarching->SetSpeedConstant( 4.0 );
CastFilterType::Pointer caster2 = CastFilterType::New();
CastFilterType::Pointer caster3 = CastFilterType::New();
CastFilterType::Pointer caster4 = CastFilterType::New();
WriterType::Pointer writer2 = WriterType::New();
WriterType::Pointer writer3 = WriterType::New();
WriterType::Pointer writer4 = WriterType::New();
caster2->SetInput( gradientMagnitude->GetOutput() );
writer2->SetInput( caster2->GetOutput() );
writer2->SetFileName("/home/gustavo/temp/GeodesicActiveContourImageFilterOutput2.tif");
caster2->SetOutputMinimum( 0 );
caster2->SetOutputMaximum( 255 );
writer2->Update();
caster3->SetInput( sigmoid->GetOutput() );
writer3->SetInput( caster3->GetOutput() );
writer3->SetFileName("/home/gustavo/temp/GeodesicActiveContourImageFilterOutput3.tif");
caster3->SetOutputMinimum( 0 );
caster3->SetOutputMaximum( 255 );
writer3->Update();
caster4->SetInput( fastMarching->GetOutput() );
writer4->SetInput( caster4->GetOutput() );
writer4->SetFileName("/home/gustavo/temp/GeodesicActiveContourImageFilterOutput4.tif");
caster4->SetOutputMinimum( 0 );
示例6: levelsetIterator
void ttt::AJSegmentationDijkstraFilter<TInputAJGraph,TPlatenessImage, TVertexnessImage,TOutputAJGraph>::DoFastMarching() {
typedef itk::Image<int, NumDimensions> VoronoiImageType;
typedef itk::ImageFileWriter<VoronoiImageType> VoronoiWriterType;
typename VoronoiWriterType::Pointer voronoiWriter = VoronoiWriterType::New();
voronoiWriter->SetFileName("VertexVoronoi.mha");
typedef ttt::VoronoiTesselationImageFilter<VoronoiImageType,typename TPlatenessImage::PixelType> VoronoiFilterType;
typename VoronoiFilterType::Pointer voronoiFilter = VoronoiFilterType::New();
typedef ttt::FastMarchingImageFilter<LevelSetImageType, PlatenessImageType> FastMarchingImageFilterType;
typename FastMarchingImageFilterType::Pointer fastMarching = FastMarchingImageFilterType::New();
fastMarching->SetInput(m_Speed);
typedef typename VoronoiFilterType::NodeContainer VoronoiNodeContainer;
typedef typename VoronoiFilterType::LevelSetNodeType VoronoiNodeType;
typedef typename FastMarchingImageFilterType::NodeContainer NodeContainer;
typedef typename FastMarchingImageFilterType::NodeType NodeType;
typename NodeContainer::Pointer seeds = NodeContainer::New();
seeds->Initialize();
typename VoronoiNodeContainer::Pointer seedsVoronoi = VoronoiNodeContainer::New();
;
seedsVoronoi->Initialize();
int k = 0;
for (auto vit = this->GetInputAJGraph()->VerticesBegin(); vit != this->GetInputAJGraph()->VerticesEnd(); vit++) {
typename PlatenessImageType::PointType seedPosition = this->GetInputAJGraph()->GetAJVertex(*vit)->GetPosition();
typename PlatenessImageType::IndexType seedIndex;
this->GetPlatenessImage()->TransformPhysicalPointToIndex(seedPosition, seedIndex);
NodeType node;
const double seedValue = 0.0;
node.SetValue(seedValue);
node.SetIndex(seedIndex);
seeds->InsertElement(k, node);
VoronoiNodeType nodeVoronoi;
nodeVoronoi.SetValue(seedValue);
node.SetIndex(seedIndex);
seedsVoronoi->InsertElement(k, nodeVoronoi);
k++;
}
voronoiFilter->SetOutputSize(m_Speed->GetLargestPossibleRegion().GetSize());
voronoiFilter->SetOutputDirection(m_Speed->GetDirection());
voronoiFilter->SetOutputRegion(m_Speed->GetLargestPossibleRegion());
voronoiFilter->SetOutputSpacing(m_Speed->GetSpacing());
voronoiFilter->SetOutputOrigin(m_Speed->GetOrigin());
voronoiFilter->SetTrialPoints(seeds);
voronoiFilter->Update();
voronoiWriter->SetInput(voronoiFilter->GetOutput());
voronoiWriter->Update();
fastMarching->SetStoppingValue(m_StoppingValue);
fastMarching->SetTrialPoints(seeds);
fastMarching->SetOutputSize(m_Speed->GetBufferedRegion().GetSize());
fastMarching->SetVoronoiImage(voronoiFilter->GetOutput());
fastMarching->Update();
m_LevelSet = fastMarching->GetOutput();
m_Labels = fastMarching->GetClusterImage();
itk::ImageRegionIterator<LevelSetImageType> levelsetIterator(m_LevelSet, m_LevelSet->GetLargestPossibleRegion());
levelsetIterator.GoToBegin();
while (!levelsetIterator.IsAtEnd()) {
if (levelsetIterator.Value() == static_cast<double>(itk::NumericTraits<double>::max() / 2.0)) {
levelsetIterator.Set(-1);
}
++levelsetIterator;
}
typedef itk::ImageFileWriter<LevelSetImageType> LevelSetWriterType;
typename LevelSetWriterType::Pointer levelSetWriter = LevelSetWriterType::New();
levelSetWriter->SetFileName("LevelSet.mha");
levelSetWriter->SetInput(m_LevelSet);
levelSetWriter->Update();
}
示例7: geodesicActiveContourShapePriorLevelSetImageFilterWorkflowITK
//.........这里部分代码省略.........
else if (initLevelSet_.isSelected("fastmarching")){
inputIsBinary_.setVisible(false);
squaredDistance_.setVisible(false);
useImageSpacing_.setVisible(false);
//initial Level set using FastMarchingImageFilter
typedef itk::FastMarchingImageFilter<
InputImageType,
InputImageType > FastMarchingFilterType;
typename FastMarchingFilterType::Pointer fastMarching = FastMarchingFilterType::New();
typedef typename FastMarchingFilterType::NodeContainer NodeContainer;
typedef typename FastMarchingFilterType::NodeType NodeType;
typename NodeContainer::Pointer seeds = NodeContainer::New();
if (seedPointPort_.hasChanged()) {
const PointListGeometry<tgt::vec3>* pointList = dynamic_cast< const PointListGeometry<tgt::vec3>* >(seedPointPort_.getData());
if (pointList) {
seedPoints = pointList->getData();
if (!seedPoints.empty()) {
numSeedPoint_.setMinValue(1);
numSeedPoint_.setMaxValue(seedPoints.size());
numSeedPoint_.set(seedPoints.size());
}
else {
numSeedPoint_.setMinValue(0);
numSeedPoint_.setMaxValue(0);
numSeedPoint_.set(0);
}
}
}
if(!seedPoints.empty()) {
seedPoint_.set(seedPoints[numSeedPoint_.get()-1]);
}
else {
seedPoint_.set(tgt::vec3 (1));
}
typename InputImageType::IndexType seedPosition;
seedPosition[0] = seedPoint_.get().x;
seedPosition[1] = seedPoint_.get().y;
seedPosition[2] = seedPoint_.get().z;
const double initialDistance = initialDistance_.get();
NodeType node;
const double seedValue = - initialDistance;
node.SetValue( seedValue);
node.SetIndex (seedPosition);
seeds->Initialize();
seeds->InsertElement( 0, node);
fastMarching->SetTrialPoints( seeds );
fastMarching->SetSpeedConstant( 1.0f );
fastMarching->SetStoppingValue( stoptime_.get() );
fastMarching->SetInput(p1);
observe(levelfilter2.GetPointer());
levelfilter2->SetInput(fastMarching->GetOutput());
levelfilter2->SetFeatureImage (sigmoid->GetOutput());
levelfilter2->SetPropagationScaling(propagationScaling_.get());
levelfilter2->SetCurvatureScaling( 1.0 );
levelfilter2->SetAdvectionScaling( 1.0 );
levelfilter2->SetMaximumRMSError( 0.02 );
levelfilter2->SetNumberOfIterations( 800 );
try
{
levelfilter2->Update();
}
catch (itk::ExceptionObject &e)
{
LERROR(e);
}
Volume* outputVolume1 = 0;
outputVolume1 = ITKToVoreenCopy<T>(levelfilter2->GetOutput());
if (outputVolume1) {
transferTransformation(inport1_.getData(), outputVolume1);
outport1_.setData(outputVolume1);
}
else
outport1_.setData(0);
}
}
开发者ID:151706061,项目名称:Voreen,代码行数:101,代码来源:geodesicactivecontourshapepriorlevelsetimagefilterworkflow.cpp