ParamGrid#
Explore relationships between different parameters of an input function.
Using ParamGrid
, we can map a function to the image and explore the interplay between different parameters of the function.
In the example below, we are using the median
filter function on the input image pol
and exploring how the pol
image would look with different median filter size
. The col
parameter is set to "size"
which means that the different size
filters will be plotted along the column of the grid.
The function to be mapped can be any callable function that takes image data as its first input or one of the implemented image filters in seaborn-image (
isns.implemented_filters()
)
[1]:
import seaborn_image as isns
from scipy.ndimage import median_filter as median
isns.set_context("notebook")
isns.set_image(cmap="inferno") # set default colormap to inferno
# sample dataset
pol = isns.load_image("polymer")
g = isns.ParamGrid(pol, median, col="size", size=[3,4,5,7])
We can also specify the col_wrap
parameter to only have a grid of the specified size.
Below,
'median'
passed as a string is looking throughseaborn_image.implemented_filters()
for the corresponding function. As a side note, theseimplemented_filters
exist primarily for convenience and are generally the common filters one would use for typical image analysis.
[2]:
g = isns.ParamGrid(pol, "median", col="size", size=[3,4,5,7], col_wrap=2)
We can specify different parameters across the row
and col
of the grid.
In the example below, we are plotting different percentile
parameters across row
and different size
parameters across col
for a percentile
function applied to the input pol
image.
[3]:
g = isns.ParamGrid(pol,
"percentile",
row="percentile",
col="size",
percentile=[3, 5, 7, 10],
size=[3, 5, 7, 10]
)
We can also specify additional parameters that need to be passed to the input function. Here, mode=reflect
is the additional parameter passed to the median
filter function and is constant across all the different size
parameters.
[4]:
g = isns.ParamGrid(pol, "median", col="size", size=[2,3,4,5], mode="reflect")
We can also specify additional parameters for ParamGrid
. Here, we are additionally specifying the parameters relevant for adding a scale bar (dx
and units
)
[5]:
scale = {"dx" : 15, "units" : "nm"}
g = isns.ParamGrid(pol,
median,
col="size",
size=[2,3,4,5],
mode="reflect",
col_wrap=2,
**scale
)