Commit 041e3bef authored by lucasb-eyer's avatar lucasb-eyer
Browse files

Allow scalar `schan` in `create_pairwise_bilateral`.

parent 3381ed43
import numpy as np import numpy as np
from numbers import Number
from logging import warning from logging import warning
...@@ -142,8 +143,12 @@ def create_pairwise_bilateral(sdims, schan, img, chdim=-1): ...@@ -142,8 +143,12 @@ def create_pairwise_bilateral(sdims, schan, img, chdim=-1):
im_feat = np.rollaxis(img, chdim).astype(np.float32) im_feat = np.rollaxis(img, chdim).astype(np.float32)
# scale image features per channel # scale image features per channel
for i, s in enumerate(schan): # Allow for a single number in `schan` to broadcast across all channels:
im_feat[i] /= s if isinstance(schan, Number):
im_feat /= schan
else:
for i, s in enumerate(schan):
im_feat[i] /= s
# create a mesh # create a mesh
cord_range = [range(s) for s in im_feat.shape[1:]] cord_range = [range(s) for s in im_feat.shape[1:]]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment