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 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.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34b53fd22e5293957557e6e60c9003601ae6b3fa8e1a8b8a48dc68e08a373a2c |
|
MD5 | c92062d5fbeef940f8ecfaa555bd851c |
|
BLAKE2b-256 | 6104d2fa8f59dd4a55f446a7dd8a2b1819f9820b38e374d686b61ae1200ae35d |