Skip to content

Commit

Permalink
Removed unnecessary copying of data from implementation of the new fe…
Browse files Browse the repository at this point in the history
…ature accumulation and changed name of the function exposed to python to accumulateEdgeStatistics
  • Loading branch information
constantinpape committed Mar 17, 2016
1 parent 987a7bc commit 1aa1f6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions vigranumpy/lib/__init__.py
Expand Up @@ -1223,12 +1223,12 @@ def accumulateEdgeFeatures(self,edgeFeatures,acc='mean',out=None):
else:
return graphs._ragEdgeFeatures(self,graph,affiliatedEdges,edgeFeatures,weights,acc,out)

def accumulateEdgeFeaturesNew(self, edgeFeatures, out=None):
def accumulateEdgeStatistics(self, edgeFeatures, out=None):
if not isinstance(self, RegionAdjacencyGraph):
raise AttributeError("accumulateEdgeFeaturesNew not implemented for " + type(self))
graph = self.baseGraph
affiliatedEdges = self.affiliatedEdges
out = graphs._ragEdgeFeaturesNew(self, graph, affiliatedEdges, edgeFeatures, out)
out = graphs._ragEdgeStatistics(self, graph, affiliatedEdges, edgeFeatures, out)
return out

def accumulateNodeFeatures(self,nodeFeatures,acc='mean',out=None):
Expand Down
11 changes: 5 additions & 6 deletions vigranumpy/src/core/export_graph_rag_visitor.hxx
Expand Up @@ -162,7 +162,7 @@ public:
python::arg("out")=python::object()
)
);
python::def("_ragEdgeFeaturesNew",
python::def("_ragEdgeStatistics",
registerConverters(
&pyRagEdgeFeaturesFromImplicit< float, float, ImplicitEdgeMap >
),
Expand Down Expand Up @@ -689,11 +689,10 @@ public:
n_bins = std::max( n_bins_min, std::min(n_bins, n_bins_max) );
a.setHistogramOptions(HistogramOptions().setBinCount(n_bins));

// copy values to multi array
MultiArray<1, double> data( Shape1(affEdges.size()) );
for(size_t i=0;i<affEdges.size();++i)
data(i) = otfEdgeMap[affEdges[i]];
extractFeatures(data.begin(), data.end(), a);
// accumulate the values of this edge
for(unsigned int k=1; k <= a.passesRequired(); ++k)
for(size_t i=0;i<affEdges.size();++i)
a.updatePassN( otfEdgeMap[affEdges[i]], k );

feat[0] = get<Mean>(a);
feat[1] = get<Sum>(a);
Expand Down

0 comments on commit 1aa1f6d

Please sign in to comment.