Skip to content

76 image comparison

image image image

Comparing images with an interactive slider

Uncomment the following line to install leafmap if needed.

Note that the image_comparison will only work with Jupyter Notebook or JupyterLab. It seems not working with Visual Studio Code.

1
# %pip install -U leafmap
1
import leafmap
1
2
img1 = "https://opengeos.org/data/images/berkeley.jpg"
img2 = "https://opengeos.org/data/images/berkeley_sam.jpg"

The labels might not show up the first time. Try running the code block again to show the labels.

1
2
3
4
5
6
7
8
leafmap.image_comparison(
    img1,
    img2,
    label1="Satellite Image",
    label2="Image Segmentation",
    starting_position=50,
    out_html="image_comparison.html",
)