Skip to main content
Images are naturally represented as multi-dimensional arrays. A grayscale image is a 2-D array of pixel intensities, while a color image is a 3-D array with a channel dimension. numpy-ts provides the array operations needed for common image processing tasks.

Representing images as 2D/3D arrays


Slicing regions of interest

Extract sub-images using NumPy-style slicing.

Element-wise transforms: brightness and contrast

Adjust pixel values using vectorized arithmetic — no loops required.

Reshaping and transposing for channel reordering

Different frameworks expect different axis orderings. Use transpose and reshape to convert between them.

Simple convolution filter

Apply spatial filters to images using convolution. For a 2-D image, convolve each row and column separately using 1-D convolution, or build a simple approach using element-wise operations.
For large-scale 2-D convolution, consider using the FFT approach: pad the image and kernel to the same size, multiply their FFTs, and inverse-transform the result. This runs in O(N log N) instead of O(N * K).