mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-03 23:16:34 +08:00
Use a strided 1-element array as dummy filter out
When using generic_filter to build a graph, the numerical filter output is actually ignored. Building a full array, even of the smallest dtype, was wasteful. Using stride_tricks solves this by creating a single-element buffer into which all output is fed.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import networkx as nx
|
||||
import numpy as np
|
||||
from numpy.lib.stride_tricks import as_strided
|
||||
from scipy import ndimage as ndi
|
||||
import math
|
||||
from ... import draw, measure, segmentation, util, color
|
||||
@@ -124,7 +125,9 @@ class RAG(nx.Graph):
|
||||
function=_add_edge_filter,
|
||||
footprint=fp,
|
||||
mode='nearest',
|
||||
output=np.empty(label_image.shape, dtype=np.uint8),
|
||||
output=as_strided(np.empty((1,), dtype=np.float_),
|
||||
shape=label_image.shape,
|
||||
strides=((0,) * label_image.ndim)),
|
||||
extra_arguments=(self,))
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user