Image library
This Module provide factory and utility for imaging processing
Refer to API:
neuralib.imglib
Array Factory
This module defines the ImageArrayWrapper, a subclass of numpy.ndarray that wraps image data and provides chainable image processing methods. It allows you to process images fluently using a series of method calls, and then display or further analyze the results as a standard NumPy array.
Example of Chainable Processing
from neuralib.imglib.array import image_array
import matplotlib.pyplot as plt
# Load an image (from a file path or a NumPy array)
img = image_array("path/to/image.jpg")
# Process the image: convert to grayscale, apply Gaussian blur, then perform edge detection.
processed = img.to_gray().gaussian_blur(ksize=[5, 5], sigma_x=2.0, sigma_y=2.0).canny_filter()
# Display the processed image using matplotlib.
plt.imshow(processed, cmap='gray')
plt.title("Processed Image")
plt.show()
Method Reference
Method |
Description |
|---|---|
Converts the image to grayscale. |
|
Flips the image vertically (upside down). |
|
Flips the image horizontally (left-to-right). |
|
Extracts a specified color channel (e.g. ‘r’, ‘g’, or ‘b’) as a grayscale image. |
|
Converts a multi-channel image to a 2D representation (grayscale) with an option to flip vertically. |
|
Applies a Gaussian blur to the image using the specified kernel size and sigma values. |
|
Applies the Canny edge detection algorithm on the grayscale version of the image. |
|
Converts the image to a binary image using thresholding. |
|
Denoises the image using non-local means denoising. |
|
Enhances the image contrast via histogram equalization. |
|
Computes the local maxima on a specified color channel after channel extraction. |
CV2 Labeller
Simple CV2-based viewer/labeller GUI for image sequences
Use Cases:
viewing the image sequences
label each image and save as csv dataframe (human-eval for population neurons activity profile)
Load sequences from a directory
See Option
$ python -m neuralib.imglib.labeller -h
Example
$ python -m neuralib.imglib.labeller -D <DIR>
API call
from neuralib.imglib.labeller import SequenceLabeller
directory = ...
labeller = SequenceLabeller.load_from_dir(directory)
labeller.main()
Load sequences from sequences array
from neuralib.imglib.labeller import SequenceLabeller
arr = ... # numpy array with (F, H, W, <3>)
labeller = SequenceLabeller.load_sequences(arr)
labeller.main()