Astra Image 6.0
Home
  • Welcome
  • Getting Started
    • Overview
    • System Requirements
    • Post Installation
  • Getting Started
    • Opening Images
    • Viewing Images
    • Saving and Exporting
    • Printing Images
    • Preferences and Settings
  • Adjustment Tools
    • Introduction to Adjustment Tools
    • Applying Changes and Color Space
    • Levels
    • Light
    • Color
    • Contrast
    • Curves
  • Processing Tools
    • Auto Enhancement
    • Deconvolution
    • Remove Camera Shake
    • Remove Focus Blur
    • Multiscale Contrast
    • Wavelet Sharpen
    • Unsharp Mask
    • Texture and Edge Sharpen
    • Histogram Equalization
    • Smart Gamma Correction
    • Shadows and Highlights
    • Color Balance
    • Channel Mixer
    • Color Temperature
    • Hyperbolic Arcsine Curve
    • Exponential Scale
    • Invert
    • Denoise
    • Convert to Gray
    • Arithmetic Filter
    • Convolution Filters
    • Edge Aware Filter
    • Pixel Math
    • Threshold
  • Image Geometry
    • Resize
    • Flip / Crop / Rotate
  • Statistics and Measurement
    • Statistics
    • Metadata
    • Measurement and Analysis
    • Pixel Information
  • Python Scripts
    • Installing Python
    • Writing Scripts
    • Function Reference
  • Activation
    • Activate Astra Image
  • Information and Credits
    • Contact Information
    • Credits
Powered by GitBook
On this page
  1. Python Scripts

Writing Scripts

No writer's block here.

You can use the built-in script editor to write a script, or you could use another editor (live Visual Studio Code) and copy and paste the code into the Astra Image editor. Please be careful when opening a script from at third party, as Python has the ability to modify your system.

Example The following example shows the basic flow of using Python with Astra Image. Please note that all image data is normalized (i.e. in the range 0.0 to 1.0). When the image data has been processed in Python, Astra Image expects the result to also be normalized between 0.0 to 1.0.

import AstraImage as ai import numpy as np import cv2

# Get the image data from Astra Image and put into a numpy array data = np.frombuffer(ai.getImageDataFloat(), dtype=np.float32)

# You can set the shape of the array if needed. data.shape = (ai.getWidth(), ai.getHeight(), 3)

# Do something with the data. data = (1.0 - data)

# Update the image data in Astra Image ai.setImageDataFloat(data.tobytes(), ai.getWidth(), ai.getHeight())

In this example, the image data is retrieved from Astra Image and loaded into a numpy array. In this case, an inverted image is generated with a simple numpy operation:

data = (1.0 - data)

After modifying the image, the data is updated in Astra Image.

PreviousInstalling PythonNextFunction Reference

Last updated 11 months ago