Blend Between Multiple Images in JupyterLab.
Project description
Jupyter compare_view
Blend between multiple images using a cell magic in JupyterLab.
Installation
pip install jupyter_compare_view
Example
import jupyter_compare_view
%%splity
from skimage import data
from skimage.color import rgb2gray
import matplotlib.pyplot as plt
img = data.chelsea()
grayscale_img = rgb2gray(img)
fig, ax1 = plt.subplots()
ax1.axis("off")
ax1.imshow(img)
fig, ax2 = plt.subplots()
ax2.axis("off")
ax2.imshow(grayscale_img, cmap="gray")
Note: The split view widget is still responsive after closing and reopening the notebook without running the cell again.
Another example:
%%splity --position 73% --height auto
import matplotlib.pyplot as plt
import numpy as np
array1 = np.full((15, 30), 10)
array2 = np.random.randint(0, 10, size=(15, 30))
fig, ax1 = plt.subplots(figsize=(5, 10))
ax1.imshow(array1)
fig, ax2 = plt.subplots(figsize=(5, 10))
ax2.imshow(array2)
Notebook arguments
(Might still change in future)
-
--config '{"start_mode": "horizontal"}'
will init the compare-view in horizontal slider mode. -
--config '{"circle_size": 30}'
the circle size is now 30 pixel in circle mode. -
--config '{"show_slider": false}'
will hide the slider bar. -
--config '{"start_slider_pos": 0.73}'
will set the slider start position to 73%.- Removed in 0.1.1:
--position 73%
will no longer the slider start position to 73%.
- Removed in 0.1.1:
-
--config '{"start_mode": "horizontal","start_slider_pos": 0.73}'
will both set the start mode to horizontal and set the slider position -
--height 220
will set the height to 220 pixel. -
When
--height
is not provided, the default height of the widget is 300 pixel. -
--height auto
will set the height by the value of the first image's resolution in vertical direction. -
The widget's width will always be adjusted automatically.
Notebook formatting
Formatting with black can be done this way:
pip install 'black[jupyter]'
black --python-cell-magics splity compare_view_magic.ipynb
Developer Installation
git clone --recurse https://github.com/Octoframes/jupyter_compare_view
(Note: In case that the repo was already cloned e.g. with the GitHub Desktop client, the GitHub submodule has to be loaded viagit submodule update --init --recursive
)poetry install
Changelog
Milestones / Wishlist
-
implement tests, find out how to test a magic class
-
Idea: Second option without using cell magic:
from jupyter_compare_view import Splity # (does not yet exist)
my_splity = Splity(left_layer=img1, right_layer=img2)
display(my_splity)
-
Make this work also in VSCode notebooks, see this issue.
-
Some other nice views, like these:
Round Mask:
Double Round Mask, Second one with 50% opacity:
Gaussian Mask (no priority):
0.1.2
- Move the repo from kolibril13/jupyter-spitview to octoframes/jupyter_compare_view
- Rename all references
0.1.1
- Drop the github.com/NUKnightLab/juxtapose backend and replace it with github.com/Octoframes/compare_view.
- Implement horizontal slider
- Implement Round Mask
0.1.0
- Update dependencies
- Update JupyterLite version
- Fix: in JupyterLite, a figure has to be explicitly called by plt.show()
- Better installation workflow
0.0.8
- Fixing problem with cell id and notebook reloading
- Experimentally lowering the dependencies to
ipython = ">=6.0.0"
andipykernel = ">=5.0.0"
so that jupyterlite will work hopefully.
0.0.7
- Rewrite of the import of JavaScript and CSS to make it more robust when closing and opening the notebook
- First attempt to add a JupyterLite example.
0.0.6
Fix poetry workflow
0.0.5
- Ship the javascript directly with the package, so no internet connection is required
- use jinja2 to save HTML in separate file
- load stylesheet and javascript only once in the beginning, and not in every cell that contains the splitview widget.
0.0.4
- New
--height
parameter
0.0.3
- default slider position
- updated minimal example
- internal code restructuring and formatting
- Handle import in non jupyter context
0.0.2
- save images in base64 strings and don't load images to disk (increases package security).
0.0.1
- First release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file jupyter_compare_view-0.1.2.tar.gz
.
File metadata
- Download URL: jupyter_compare_view-0.1.2.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.14 CPython/3.9.13 Linux/5.13.0-1031-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dcdcd081ff2b7c052dd1141ef30dcbff4e7e915d99b76b881088f6c31a8332ae |
|
MD5 | 613f6fef21a7d659b2769854013c3b88 |
|
BLAKE2b-256 | 8ed6ec4509bf9ea8dacc4a5c799e136cb0a8fc5bb197978ca56a97a8e290e8ea |
File details
Details for the file jupyter_compare_view-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: jupyter_compare_view-0.1.2-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.14 CPython/3.9.13 Linux/5.13.0-1031-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aba8d725196149913dd4bb0092e4dff239598299c09e218cc30ee2a064383248 |
|
MD5 | 760e5587a58194a9ed7872a99162414f |
|
BLAKE2b-256 | e1f87a555b09541676abd15ec4037ba2badb4bf1804e4e0bc6f34763a7260a2b |