Skip to main content

Python wrapper for ImageJ

Project description

Python wrapper for ImageJ

pyimagej provides a set of wrapper functions for integration between ImageJ and Python.

It also provides a high-level entry point imagej.IJ for invoking ImageJ Server APIs; see "ImageJ Server" below for details.

Requirements

Install dependencies using conda env create -f environment.yml.

See also:

Usage

Creating the ImageJ gateway

Newest available version

If you want to launch the newest available release version of ImageJ:

import imagej
ij = imagej.init()

This invocation will automatically download and cache the newest release of net.imagej:imagej.

With graphical capabilities

If you want to have support for the graphical user interface:

import imagej
ij = imagej.init(headless=False)
ij.ui().showUI()

Note there are issues with Java AWT via Python on macOS; see this article for a workaround.

Including ImageJ 1.x support

By default, the ImageJ gateway will not include the legacy layer for backwards compatibility with ImageJ 1.x. You can enable the legacy layer as follows:

import imagej
ij = imagej.init('net.imagej:imagej+net.imagej:imagej-legacy')

Including Fiji plugins

By default, the ImageJ gateway will include base ImageJ2 functionality only, without additional plugins such as those that ship with the Fiji distribution of ImageJ.

You can create an ImageJ gateway including Fiji plugins as follows:

import imagej
ij = imagej.init('sc.fiji:fiji')

From a local installation

If you have an installation of ImageJ2 such as Fiji, you can wrap an ImageJ gateway around it:

import imagej
ij = imagej.init('/Applications/Fiji.app')

Replace /Applications/Fiji.app with the actual location of your installation.

Using the ImageJ gateway

Once you have your ImageJ gateway, you can start using it. Here is an example:

# Import an image with scikit-image.
import skimage
from skimage import io
# NB: Blood vessel image from: https://www.fi.edu/heart/blood-vessels
img = io.imread('https://www.fi.edu/sites/fi.live.franklinds.webair.com/files/styles/featured_large/public/General_EduRes_Heart_BloodVessels_0.jpg')
import numpy as np
img = np.mean(img, axis=2)

# Invoke ImageJ's Frangi vesselness op.
vessels = np.zeros(img.shape, dtype=img.dtype)
ij.op().filter().frangiVesselness(ij.py.to_java(vessels), ij.py.to_java(img), [1, 1], 20)

See also test/test_imagej.py for other examples of usage.

ImageJ Server

Requirements

The imagej.server module has its own requirements:

  • requests is required to communicate with the ImageJ server.
  • pillow is required for the imagej.server.IJ.show() function. In addition, display or xv must be available to view the image.

Usage

There is a short usage example here.

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

pyimagej-0.4.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

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

pyimagej-0.4.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file pyimagej-0.4.0.tar.gz.

File metadata

  • Download URL: pyimagej-0.4.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/36.5.0.post20170921 requests-toolbelt/0.8.0 tqdm/4.23.3 CPython/3.6.3

File hashes

Hashes for pyimagej-0.4.0.tar.gz
Algorithm Hash digest
SHA256 523dd9a9a52639e786fc8639a028131ddcbdfacf7f89609f1df96b7dd784f61c
MD5 9ea8bab1a8d059df4837f0e1646a1802
BLAKE2b-256 68a4d22ea494423f7a4c7ca99b31ea7f1007b9f6bd4e9221c04a67a0373dbc58

See more details on using hashes here.

File details

Details for the file pyimagej-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: pyimagej-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/36.5.0.post20170921 requests-toolbelt/0.8.0 tqdm/4.23.3 CPython/3.6.3

File hashes

Hashes for pyimagej-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 11472afef43d61046c83a3aad318a1430bc11876e88044a288954fdafa8dbd29
MD5 c3020b50891314c957d92b152192f58c
BLAKE2b-256 c9deea24d0e71c00b9f66be7063c3e2a8c1d3c8b787ba768f31b6aab7f5d50c5

See more details on using hashes here.

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