Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ot/bregman.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Titouan Vayer <[email protected]>
# Hicham Janati <[email protected]>
# Mokhtar Z. Alaya <[email protected]>
# Alexander Tong <[email protected]>
#
# License: MIT License

Expand Down Expand Up @@ -1346,12 +1347,17 @@ def convolutional_barycenter2d(A, reg, weights=None, numItermax=10000,
err = 1

# build the convolution operator
# this is equivalent to blurring on horizontal then vertical directions
t = np.linspace(0, 1, A.shape[1])
[Y, X] = np.meshgrid(t, t)
xi1 = np.exp(-(X - Y)**2 / reg)

t = np.linspace(0, 1, A.shape[2])
[Y, X] = np.meshgrid(t, t)
xi2 = np.exp(-(X - Y)**2 / reg)

def K(x):
return np.dot(np.dot(xi1, x), xi1)
return np.dot(np.dot(xi1, x), xi2)

while (err > stopThr and cpt < numItermax):

Expand Down
7 changes: 7 additions & 0 deletions test/test_bregman.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,10 @@ def test_screenkhorn():
# check marginals
np.testing.assert_allclose(G_sink.sum(0), G_screen.sum(0), atol=1e-02)
np.testing.assert_allclose(G_sink.sum(1), G_screen.sum(1), atol=1e-02)


def test_convolutional_barycenter_non_square():
# test for image with height not equal width
A = np.ones((2, 2, 3)) / (2 * 3)
b = ot.bregman.convolutional_barycenter2d(A, 1e-03)
np.testing.assert_allclose(np.ones((2, 3)) / (2 * 3), b, atol=1e-02)