Skip to content

Commit 3c4944c

Browse files
committed
add notebook for color transfer in images
1 parent 3f46a24 commit 3c4944c

File tree

4 files changed

+348
-1
lines changed

4 files changed

+348
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ The examples folder contain several examples and use case for the library. The f
6464
* [1D Wasserstein barycenter](https://github.com/rflamary/POT/blob/master/examples/Demo_1D_barycenter.ipynb)
6565
* [OT with user provided regularization](https://github.com/rflamary/POT/blob/master/examples/Demo_Optim_OTreg.ipynb)
6666
* [Domain adaptation with optimal transport](https://github.com/rflamary/POT/blob/master/examples/Demo_2D_OT_DomainAdaptation.ipynb)
67+
* [Color transfer in images](https://github.com/rflamary/POT/blob/master/examples/Demo_Image_ColorAdaptation.ipynb)
68+
6769

6870
## Acknowledgements
6971

docs/source/examples.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ Domain adaptation with optimal transport
2727
----------------------------------------
2828

2929
.. literalinclude:: ../../examples/demo_OTDA_classes.py
30+
31+
Color transfer in images
32+
------------------------
33+
34+
.. literalinclude:: ../../examples/demo_OTDA_color_images.py

examples/Demo_Image_ColorAdaptation.ipynb

Lines changed: 316 additions & 0 deletions
Large diffs are not rendered by default.

examples/demo_OTDA_color_images.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
"""
3-
demo of Optimal transport for domain adaptation with image color adaptation as in [6]
3+
Demo of Optimal transport for domain adaptation with image color adaptation as in [6]
44
55
[6] Ferradans, S., Papadakis, N., Peyré, G., & Aujol, J. F. (2014). Regularized discrete optimal transport. SIAM Journal on Imaging Sciences, 7(3), 1853-1882.
66
"""
@@ -51,6 +51,30 @@ def mat2im(X,shape):
5151
xs=X1[idx1,:]
5252
xt=X2[idx2,:]
5353

54+
#%% Plot image distributions
55+
56+
57+
pl.figure(2,(10,5))
58+
59+
pl.subplot(1,2,1)
60+
pl.scatter(xs[:,0],xs[:,2],c=xs)
61+
pl.axis([0,1,0,1])
62+
pl.xlabel('Red')
63+
pl.ylabel('Blue')
64+
pl.title('Image 1')
65+
66+
pl.subplot(1,2,2)
67+
#pl.imshow(I2)
68+
pl.scatter(xt[:,0],xt[:,2],c=xt)
69+
pl.axis([0,1,0,1])
70+
pl.xlabel('Red')
71+
pl.ylabel('Blue')
72+
pl.title('Image 2')
73+
74+
pl.show()
75+
76+
77+
5478
#%% domain adaptation between images
5579

5680
# LP problem

0 commit comments

Comments
 (0)