Skip to main content

Live tuning of image processing algorithms

Project description

IMAGETUNE

imagetune is a simple GUI to interactively tune image-processing parameters. It utilizes the hardware accellerated speed of fastplotlib to provide visual feedback that is not slowed down by plotting.

imagetune is simple to use requiring only minimal changes to your code. Simply wrap the functions you wish to tune the parameters of with tune and launch tuneui.

ImageTune

How to use

Here is a simple script to make a binary version of an image:

from skimage.filters import gaussian
from skimage import data


def threshold(im, thres_val):
    return im > thres_val


def preprocessing(im):
    bg = gaussian(im, 10)
    fg = im - bg
    segmented = threshold(fg, 0.1)
    return segmented


im = data.coins()
result = preprocessing(im)

The script depends on parameters sigma=10 for Gaussian filtering and thres_val=0.1 for the thresholding. In order to tune these live, simply wrap those functions in tune and launch tuneui:

from skimage.filters import gaussian
from skimage import data
+from imagetune import tune, tuneui


def threshold(im, thres_val):
    return im > thres_val


def preprocessing(im):
-    bg = gaussian(im, 10)
+    bg = tune(gaussian)(im, 10)
     fg = im - bg
-    segmented = threshold(fg, 0.1)
+    segmented = tune(threshold)(fg, 0.1)
    return segmented


im = data.coins()
+tuneui(preprocessing, im)

This launches a window in which the parameters are tunable interactively:

ImageTune

You can also decorate your functions instead

+@tune
def threshold(im, thres_val):
    return im > thres_val

Note that the function still works as normal:

output = preprocessing(im)

Only when you run tuneui(preprocessing, im) does it behave differently.

Installation

Install directly with pip:

pip install imagetune

Function requirements

All tunable functions are asssumed to take an image as its first input and return an image as its output.

Choosing parameters

Given a function:

def adjust(im, alpha, gamma):
    return alpha * im**gamma

The decorator tune will per standard assume you wish to tune the first parameter (alpha). You can change this by specifying argnames:

tune(adjust, argnames='gamma')

or argnums:

tune(adjust, argnums=2)

The behavior of the above is identical. You can also tune both parameters, by either

tune(adjust, argnames=('alpha', 'gamma'))

or

tune(adjust, argnums=(1, 2))

Misc

To overwrite function names in the UI, simply pass along a name:

bg = tune(gaussian, name='blur')(im, 10)

You can also choose a min, max of the parameter bar:

bg = tune(gaussian, min=0, max=300)(im, 10)

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

imagetune-0.1.0rc0.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

imagetune-0.1.0rc0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file imagetune-0.1.0rc0.tar.gz.

File metadata

  • Download URL: imagetune-0.1.0rc0.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for imagetune-0.1.0rc0.tar.gz
Algorithm Hash digest
SHA256 dae5cd7901bb8a154c6c71f25ba60c1eed128864ed2fe12374f74a5052d8401b
MD5 cd5451de9915a5cf3ea18e365f8408b6
BLAKE2b-256 a98d651b53efe929fc1bc21b3b9dbe2977dd7c309fb6070ee3625eb4e0039e57

See more details on using hashes here.

Provenance

The following attestation bundles were made for imagetune-0.1.0rc0.tar.gz:

Publisher: publish.yml on juliusbierk/imagetune

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file imagetune-0.1.0rc0-py3-none-any.whl.

File metadata

  • Download URL: imagetune-0.1.0rc0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for imagetune-0.1.0rc0-py3-none-any.whl
Algorithm Hash digest
SHA256 cb5ba4fce09ad41da9a78adfe54de358ec03e2d51438c28a2a753af97efc7727
MD5 cff533890d9ebdffc3128e7fba4b4c80
BLAKE2b-256 1ea8fd6f3ddb260c70be9a21af4d2b5f02e47a3cb4c1771b8d26d1aac2216297

See more details on using hashes here.

Provenance

The following attestation bundles were made for imagetune-0.1.0rc0-py3-none-any.whl:

Publisher: publish.yml on juliusbierk/imagetune

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page