neuralib.imglib.array

image_array

Image array numpy subclass

ImageArrayWrapper

Subclass of numpy.ndarray that wraps an image and provides chainable image processing methods

Image Array

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

from neuralib.imglib.processor 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

to_gray()

Converts the image to grayscale.

flipud()

Flips the image vertically (upside down).

fliplr()

Flips the image horizontally (left-to-right).

select_channel(channel)

Extracts a specified color channel (e.g. ‘r’, ‘g’, or ‘b’) as a grayscale image.

view_2d(flipud=False)

Converts a multi-channel image to a 2D representation (grayscale) with an option to flip vertically.

gaussian_blur(ksize, sigma_x, sigma_y)

Applies a Gaussian blur to the image using the specified kernel size and sigma values.

canny_filter(threshold_1, threshold_2)

Applies the Canny edge detection algorithm on the grayscale version of the image.

binarize(thresh, maxval)

Converts the image to a binary image using thresholding.

denoise(h, temp_win_size, search_win_size)

Denoises the image using non-local means denoising.

enhance_contrast()

Enhances the image contrast via histogram equalization.

local_maxima(channel)

Computes the local maxima on a specified color channel after channel extraction.