junkie_picasso adds abstract functionality to the junkie JUpyter NotebooK Image Explorer
Project description
JuNkIE-picasso: abstract functionality for Junkie
JuNkIE-picasso adds onto the functionality of JuNkIE, allowing you to not just explore your images, but also the parameter space of your image processing pipeline.
Installing JuNkIE-picasso
To install JuNkIE-picasso, type:
$ python3 -m pip install --no-cache-dir -U junkie-picasso
We do most of the development and testing of JuNkIE-picasso in Jupyter Lab, so we recommend using Jupyter Lab.
A note on the Python interpreter
JuNkIE-picasso requires that you have Python 3.10 or above installed.
Importing JuNkIE-picasso
JuNkIE-picasso uses matplotlib and ipywidgets, so there is some boiler plate code that you need before importing JuNkIE-picasso:
import matplotlib
%matplotlib widgets
from junkie_picasso import junkie
Using JuNkIE
For details on how to use the basic functionality of JuNkIE, visit the JuNkIE docs.
Adding abstract functions
JuNkIE-picasso allows the user to define abstract image processing functions that will be applied to the input image. This allows you to explore the parameter space of your image processing pipeline without re-writing and re-running your code!
First, import the abstract function base class:
from junkie_picasso.functions.abstractfunction import AbstractFunction
Next, define a class which details the parameters you want to explore using class variables and the function which updates the image using a class method "update". You will need to know a little bit about which widgets you want to use to change the parameters in the GUI. Here is an example for a simple function that adds an offset to the image:
class add_offset():
parameters = {"offset": {"type": "intslider", "range": [0, 10000], "step": 1, "value": 0}}
def update(self, image: numpy.ndarray) -> numpy.ndarray:
return image + self.parameters["offset"]["value"]
Finally, create a JuNkIE-picasso instance using your custom class as an additional parameter:
ayim = junkie('/path/to/img.tiff', func=add_offset())
The parameters you have defined will appear to the right of the default JuNkIE parameters in a tabbed box, with each tab corresponding to a different parameter. This allows for an arbitrary number of parameters to be added without reorganizing the widget layout.
Possible parameter types
For all parameter types, the dict must have:
- a "value" key initialized with the default value
- a "type" key with one of the following widget names
- any other keys required by that widget, as follows
- "checkbox" (bool value)
- "intslider" (int value)
- "range": a tuple of ints denoting the minimum and maximum extents of the slider
- "step": an int describing the step size for when the slider is moved
- "floatslider" (float value)
- "range": a tuple of floats denoting the minimum and maximum extents of the slider
- "step": a float describing the step size for when the slider is moved
- "inttext" (int value)
- "floattext" (float value)
- "radiobuttons" (str value)
- "options": a list of strings denoting the different options for each radio button
Citing JuNkIE-picasso
If you use JuNkIE-picasso, please cite this repository and the repository for the original JuNkIE. We are working on the paper!
Sponsors
We are grateful for the generous support from the following agencies and institutions, which contribute to the development and maintenance of JuNkIE and JuNkIE-picasso:
Project details
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
Hashes for junkie_picasso-2023.9.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8d6b6b6cef41a0ea14021b7b9ccfbe2250e994311e134ea2b6181f46fe242c4 |
|
MD5 | 5f810462e469c89eee98aebd8d8cc1a6 |
|
BLAKE2b-256 | bb31ab4f8a59dcdad6b4ed6488c7c6d2794fe4db815af50b40070608f71adda6 |