本文整理汇总了C++中vtkSmartPointer::AddColumn方法的典型用法代码示例。如果您正苦于以下问题:C++ vtkSmartPointer::AddColumn方法的具体用法?C++ vtkSmartPointer::AddColumn怎么用?C++ vtkSmartPointer::AddColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vtkSmartPointer
的用法示例。
在下文中一共展示了vtkSmartPointer::AddColumn方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetObjectCentroids
//**************************************************************************************
//**************************************************************************************
//**************************************************************************************
//**************************************************************************************
void IntrinsicFeatureCalculator::GetObjectCentroids(vtkSmartPointer<vtkTable> table, int time)
{
if(!intensityImage || !labelImage)
{
return;
}
//Compute features:
typedef ftk::LabelImageToFeatures< IPixelT, LPixelT, 3 > FeatureCalcType;
FeatureCalcType::Pointer labFilter = FeatureCalcType::New();
if(useRegion)
{
labFilter->SetImageInputs( intensityImage->GetItkPtr<IPixelT>(time,intensityChannel), labelImage->GetItkPtr<LPixelT>(time,labelChannel), regionIndex, regionSize );
}
else
{
labFilter->SetImageInputs( intensityImage->GetItkPtr<IPixelT>(time,intensityChannel), labelImage->GetItkPtr<LPixelT>(time,labelChannel) );
}
labFilter->Update();
//Init the table (headers):
vtkSmartPointer<vtkDoubleArray> column = vtkSmartPointer<vtkDoubleArray>::New();
column->SetName( "centroid_x" );
column->SetNumberOfValues(table->GetNumberOfRows());
table->AddColumn(column);
column = vtkSmartPointer<vtkDoubleArray>::New();
column->SetName( "centroid_y" );
column->SetNumberOfValues(table->GetNumberOfRows());
table->AddColumn(column);
column = vtkSmartPointer<vtkDoubleArray>::New();
column->SetName( "centroid_z" );
column->SetNumberOfValues(table->GetNumberOfRows());
table->AddColumn(column);
for (int i=0; i<(int)table->GetNumberOfRows(); ++i)
{
FeatureCalcType::LabelPixelType id = table->GetValue(i,0).ToInt();
if(useIDs)
if(IDs.find(id) == IDs.end()) continue; //Don't care about this id, so skip it
ftk::IntrinsicFeatures * features = labFilter->GetFeatures(id);
table->SetValueByName( i, "centroid_x", vtkVariant((int)features->Centroid[0]) );
table->SetValueByName( i, "centroid_y", vtkVariant((int)features->Centroid[1]) );
if( labelImage->GetImageInfo()->numZSlices > 2 )
table->SetValueByName( i, "centroid_z", vtkVariant((int)features->Centroid[2]) );
else
table->SetValueByName( i, "centroid_z", vtkVariant(0) );
}
return;
}
示例2: MetricLinePlot
MetricLinePlot(MetricBaseSPtr _metric) :
table(vtkSmartPointer<vtkTable>::New()),
arrX(vtkSmartPointer<vtkFloatArray>::New()),
arrM(vtkSmartPointer<vtkFloatArray>::New()),
view(vtkSmartPointer<vtkContextView>::New()),
chart(vtkSmartPointer<vtkChartXY>::New()),
num_gens(0),
metric(_metric)
{
arrX->SetName("Generations");
table->AddColumn(arrX);
arrM->SetName("Metric");
table->AddColumn(arrM);
view->GetRenderer()->SetBackground(1.0, 1.0, 1.0);
view->GetScene()->AddItem(chart);
}
示例3: Append
//Update the features in this table whose names match (sets doFeat)
void AssociativeFeatureCalculator::Append(vtkSmartPointer<vtkTable> table)
{
//Compute features:
ftk::NuclearAssociationRules *assoc;
if( inputs_set ){
assoc = new ftk::NuclearAssociationRules("",0,lab_im, inp_im);
assoc->AddAssociation( input_association->GetRuleName(), "", input_association->GetOutDistance(), input_association->GetInDistance(), input_association->IsUseWholeObject(), input_association->IsUseBackgroundSubtraction(), input_association->IsUseMultiLevelThresholding(), input_association->GetNumberOfThresholds(), input_association->GetNumberIncludedInForeground(), input_association->GetAssocType(), input_association->get_path() );
}
else{
assoc = new ftk::NuclearAssociationRules("",0);
assoc->ReadRulesFromXML(inFilename);
}
assoc->PrintSelf();
assoc->Compute();
//Init the table (headers):
for (int i=0; i < assoc->GetNumofAssocRules(); ++i)
{
vtkSmartPointer<vtkDoubleArray> column = vtkSmartPointer<vtkDoubleArray>::New();
column->SetName( (fPrefix+assoc->GetAssociationRules().at(i).GetRuleName()).c_str() );
column->SetNumberOfValues( table->GetNumberOfRows() );
table->AddColumn(column);
}
//Now update the table:
std::vector<unsigned short> labels = assoc->GetLabels();
float** vals = assoc->GetAssocFeaturesList();
//#pragma omp parallel for num_threads(4)
for (int i=0; i<(int)labels.size(); ++i)
{
unsigned short id = labels.at(i);
if(id == 0) continue;
int row = -1;
for(int r=0; r<table->GetNumberOfRows(); ++r)
{
if( table->GetValue(r,0) == id )
{
row = r;
break;
}
}
if(row == -1) continue;
for (int f=0; f<assoc->GetNumofAssocRules(); ++f)
{
table->SetValueByName(row,(fPrefix+assoc->GetAssociationRules().at(f).GetRuleName()).c_str(), vtkVariant(vals[f][i]));
}
}
delete assoc;
}
示例4: CopySelectedIntoTable
void SelectiveClustering::CopySelectedIntoTable(std::set<vtkIdType> selectedIDs, vtkSmartPointer<vtkTable> selectedTable)
{
/*!
* Populate a table containing selected objects
*/
//Add Header Columns
for(vtkIdType NumberOfColumns = 0; NumberOfColumns < this->ObjectTable->GetNumberOfColumns(); NumberOfColumns++ )
{
vtkSmartPointer<vtkVariantArray> col = vtkSmartPointer<vtkVariantArray>::New();
col->SetName(this->ObjectTable->GetColumnName(NumberOfColumns));
selectedTable->AddColumn(col);
}
//
std::set< vtkIdType >::iterator selectionIter = selectedIDs.begin();
for (; selectionIter != selectedIDs.end(); selectionIter++)
{
vtkIdType curSelection = *selectionIter;
this->TableIDIter = this->ObjectTableIDMap.find(curSelection);
if (this->TableIDIter != this->ObjectTableIDMap.end())
{
vtkVariantArray * RowCopy = this->ObjectTable->GetRow((*this->TableIDIter).second);
selectedTable->InsertNextRow(RowCopy);
}
}
////Code to compare timing map vs search
//vtkIdType NumRows = this->ObjectTable->GetNumberOfRows();
//for (vtkIdType row = 0; row <= this->NumberOfObjects; row++)
//{
// vtkIdType rowObjId = this->ObjectTable->GetValue(row, 0).ToTypeInt64();
// //std::cout << "Searching for obj: " << rowObjId << std::endl;
// std::set< vtkIdType >::iterator FoundAt = selectedIDs.find(rowObjId);
// if (FoundAt != selectedIDs.end())
// {
// //std::cout << "found obj: " << rowObjId << std::endl;
// vtkVariantArray * RowCopy = this->ObjectTable->GetRow(row);
// selectedTable->InsertNextRow(RowCopy);
// }
//}
}
示例5: GetDistanceToSurfaceMeasures
void IntrinsicFeatureCalculator::GetDistanceToSurfaceMeasures(vtkSmartPointer<vtkTable> table, std::vector< ftk::Object::Point > surfacePoints)
{
typedef itk::Image< IPixelT, 3 > InputImageType;
typedef itk::Image< LPixelT, 3 > OutputImageType;
typedef itk::DanielssonDistanceMapImageFilter< OutputImageType, OutputImageType > DanielssonFilterType;
typedef itk::RescaleIntensityImageFilter< OutputImageType, OutputImageType > RescalerType;
typedef itk::ImageFileReader< InputImageType > ReaderType;
typedef itk::ImageFileWriter< InputImageType > InputWriterType;
typedef itk::ImageFileWriter< OutputImageType > WriterType;
typedef itk::LineIterator< OutputImageType > LineIteratorType;
vtkSmartPointer<vtkDoubleArray> column = vtkSmartPointer<vtkDoubleArray>::New();
column->SetName( "Dist_To_Surface" );
column->SetNumberOfValues( table->GetNumberOfRows() );
table->AddColumn(column);
OutputImageType::Pointer im;
im = OutputImageType::New();
OutputImageType::PointType origin;
origin[0] = 0;
origin[1] = 0;
origin[2] = 0;
im->SetOrigin( origin );
OutputImageType::IndexType start;
start[0] = 0; // first index on X
start[1] = 0; // first index on Y
start[2] = 0; // first index on Z
OutputImageType::Pointer temp_image = labelImage->GetItkPtr< LPixelT >(0,0);
itk::Size<3> im_size = temp_image->GetBufferedRegion().GetSize();
im_size[2] = 1;
InputImageType::RegionType region;
region.SetSize( im_size );
region.SetIndex( start );
im->SetRegions( region );
im->Allocate();
im->FillBuffer(0);
im->Update();
//copy the input image into the ITK image
for(int p = 1; p < (int)surfacePoints.size(); ++p)
{
itk::Index<3> indx,indy;
indx[0] = surfacePoints[p-1].x;
indx[1] = surfacePoints[p-1].y;
indx[2] = 0;
indy[0] = surfacePoints[p].x;
indy[1] = surfacePoints[p].y;
indy[2] = 0;
LineIteratorType it( im, indx, indy );
//it.GoToBegin();
//while(!it.IsAtEnd())
for(it.GoToBegin(); !it.IsAtEnd(); ++it)
{
it.Set(255);
}
}
DanielssonFilterType::Pointer danielssonFilter = DanielssonFilterType::New();
WriterType::Pointer writer = WriterType::New();
danielssonFilter->SetInput( im );
writer->SetFileName( "DistanceMap.tif" );
danielssonFilter->InputIsBinaryOn();
danielssonFilter->Update();
OutputImageType::Pointer distMap = danielssonFilter->GetOutput();
writer->SetInput( distMap );
writer->Update();
for(int row=0; row<(int)table->GetNumberOfRows(); ++row)
{
OutputImageType::IndexType indx;
indx[0] = table->GetValue(row, 1).ToInt();
indx[1] = table->GetValue(row, 2).ToInt();
indx[2] = 0;
int dist = distMap->GetPixel(indx);
table->SetValueByName(row, "Dist_To_Surface", vtkVariant(dist));
}
}
示例6: Append
//Update the features in this table whose names match (sets doFeat)
//Will creat new rows if necessary:
void IntrinsicFeatureCalculator::Append(vtkSmartPointer<vtkTable> table)
{
if(!intensityImage || !labelImage)
return;
//Compute features:
typedef ftk::LabelImageToFeatures< IPixelT, LPixelT, 3 > FeatureCalcType;
FeatureCalcType::Pointer labFilter = FeatureCalcType::New();
if(useRegion)
{
labFilter->SetImageInputs( intensityImage->GetItkPtr<IPixelT>(0,intensityChannel), labelImage->GetItkPtr<LPixelT>(0,labelChannel), regionIndex, regionSize, cyto_image );
}
else
{
labFilter->SetImageInputs( intensityImage->GetItkPtr<IPixelT>(0,intensityChannel), labelImage->GetItkPtr<LPixelT>(0,labelChannel), cyto_image );
}
labFilter->SetLevel( needLevel() );
if( needHistogram() )
labFilter->ComputeHistogramOn();
if( needTextures() )
labFilter->ComputeTexturesOn();
labFilter->Update();
//Add new columns to the table (headers):
for (int i=0; i < IntrinsicFeatures::N; ++i)
{
if(doFeat[i])
{
vtkSmartPointer<vtkDoubleArray> column = vtkSmartPointer<vtkDoubleArray>::New();
column->SetName( (fPrefix+IntrinsicFeatures::Info[i].name).c_str() );
column->SetNumberOfValues( table->GetNumberOfRows() );
table->AddColumn(column);
}
}
//Now update the table:
std::vector< FeatureCalcType::LabelPixelType > labels = labFilter->GetLabels();
for (int i=0; i<(int)labels.size(); ++i)
{
FeatureCalcType::LabelPixelType id = labels.at(i);
if(id == 0) continue;
if(useIDs)
if(IDs.find(id) == IDs.end()) continue; //Don't care about this id, so skip it
int row = -1;
for(int r=0; r<table->GetNumberOfRows(); ++r)
{
if( table->GetValue(r,0) == id )
{
row = r;
break;
}
}
ftk::IntrinsicFeatures * features = labFilter->GetFeatures(id);
//Must Create a new row:
if(row == -1)
{
vtkSmartPointer<vtkVariantArray> nrow = vtkSmartPointer<vtkVariantArray>::New();
for( unsigned ii=0; ii<table->GetNumberOfColumns(); ++ii )
nrow->InsertNextValue( vtkVariant(0.0) );
table->InsertNextRow(nrow);
row = table->GetNumberOfRows() - 1;
table->SetValue(row, 0, vtkVariant(id));
}
for (int f=0; f<IntrinsicFeatures::N; ++f)
{
if(doFeat[f])
table->SetValueByName(row,(fPrefix+IntrinsicFeatures::Info[f].name).c_str(), vtkVariant(features->ScalarFeatures[f]));
}
}
}