Working with multi-dimensional images¶
[1]:
import seaborn_image as isns
from skimage import exposure # for adjusting image exposure
Load a sample multi-dimension image array
[2]:
cells = isns.load_image("cells")
cells.shape
[2]:
(256, 256, 60)
Plot specific slices from 3-D data¶
[3]:
g = isns.ImageGrid(cells, slices=[10,20,30,40,50,55])
/home/docs/checkouts/readthedocs.org/user_builds/seaborn-image/envs/v0.5.2/lib/python3.8/site-packages/traitlets/traitlets.py:3437: FutureWarning: --rc={'figure.dpi': 96} for dict-traits is deprecated in traitlets 5.0. You can pass --rc <key=value> ... multiple times to add items to a dict.
warn(
You can apply changes to the entire grid. Here, we hide the colorbar and change the colormap.
[4]:
g = isns.ImageGrid(cells, slices=[10,20,30,40,50,55], cbar=False, cmap="inferno")
Index along different axis¶
[5]:
g = isns.ImageGrid(
cells,
slices=[10,20,30,40,50,55],
axis=1,
cbar=False
)
Variable step sizes and start/end points¶
[6]:
g = isns.ImageGrid(
cells,
step=3,
start=10,
stop=40,
cbar=False
)
Variable column length and figure size¶
Change column length and figure size using the col_wrap
and height
parameter, respectively
[7]:
g = isns.ImageGrid(cells, cbar=False, height=1, col_wrap=10)
Map a function to transform the 3-D data¶
Here, we will adjust the exposure using the adjust_gamma
function from scikit-image
. This can done by passing the function object to the map_func
parameter. Additional parameters to the function object can be passed as kwargs.
[8]:
g = isns.ImageGrid(
cells,
map_func=exposure.adjust_gamma,
map_func_kw={"gamma" : 0.5},
cbar=False,
height=1,
col_wrap=10)
[ ]: