xp1632 / VPE_IP

0 stars 0 forks source link

PyImageJ _API_Summary #61

Open xp1632 opened 7 months ago

xp1632 commented 7 months ago
# Create an ImageJ2 gateway with the newest available version of ImageJ2.
import imagej
ij = imagej.init()

# Load an image.
image_url = 'https://imagej.net/images/clown.png'
jimage = ij.io().open(image_url)

# Convert the image from ImageJ2 to xarray, a package that adds
# labeled datasets to numpy (http://xarray.pydata.org/en/stable/).
image = ij.py.from_java(jimage)

# Display the image (backed by matplotlib).
ij.py.show(image, cmap='gray')
xp1632 commented 7 months ago

1. Initialization:

imagej.init(ij_dir_or_version_or_endpoint=None, mode: Mode| str = Mode.HEADLESS, add_legacy=True, headless=None)


  1. ij_dir_or_version_or_endpoint: defines the source of ImageJ functions, could be from

    • Maven
    • local_installation
    • we can also define the specific version of ImageJ, default is the latest version of net.imagej:imagej
  2. mode: defines how the environment will behave

    • HEADLESS: this is the default mode, to use ImageJ as a library
    • GUI: to start ImageJ2 as a GUI application
    • INTERACTIVE: to start ImageJ2 with GUI support but not displaying GUI
xp1632 commented 7 months ago

2.Convenience methods in imagej.ImageJPython :


  1. Get the active image as certain datatype : Dataset, ImagePlus, xarray image

These functions have some built-in converters: image


  1. Get the shape and dtype of Image:

image


  1. Arguments conversion:

4. ImageJ from_to_Python ImageJ type conversion:

- to specific image type of ImageJ:


5. Run plugins

image

run_marco:

plugin = "Mean"
args = {
    "block_radius_x": 10,
    "block_radius_y": 10
}
ij.py.run_plugin(plugin, args)

run_script:

language = "ijm"
script = """
#@ String name
#@ int age
output = name + " is " + age " years old."
"""
args = {
    "name": "Sean",
    "age": 26
}
script_result = ij.py.run_script(language, script, args)
print(script_result.getOutput("output"))
xp1632 commented 7 months ago

RandomAccesibleInterval operators


Addons:


ImageJ2 gateway addons :


ImagePlusAddons

xp1632 commented 7 months ago

Interval addons

Euclidean space

Typed space addons

Anntoted space addons


xp1632 commented 7 months ago

PyImageJ submodules:

imagej.dims


imagej.stack


imagej.doctor