Image processing and feature extraction

The Image class is a core component of this Toolbox. It encapsulates a NumPy array that contains the pixel values of a greyscale or color image as a 2D or 3D array respectively. An Image instance has a very large number of methods that perform useful operations on an image and wrap low-level operations performed using NumPy or OpenCV.

Image object

Basic info

width

Image width

height

Image height

size

Image size

npixels

Number of pixels in image plane

name

Set/get image name

centre

Coordinate of centre pixel

centre_int

Coordinate of centre pixel as integer

center

Coordinate of center pixel

center_int

Coordinate of centre pixel as integer

__str__

Single line summary of image parameters

__repr__

Single line summary of image parameters

Predicates

isfloat

Image has floating point pixel values?

isint

Image has integer values?

isbool

Image has bolean values?

iscolor

Image has color pixels?

isbgr

Image has BGR color order?

isrgb

Image has RGB color order?

Image coordinates

umax

Image maximum u-coordinate

vmax

Image maximum v-coordinate

uspan

Linear span of image horizontally

vspan

Linear span of image vertically

meshgrid

Coordinate arrays for image

contains

Test if coordinate lies within image

NumPy pixel data

A

Set/get the NumPy array containing pixel values

rgb

Image as NumPy array in RGB color order

bgr

Image as NumPy array in BGR color order

image

Image as NumPy array

to_int

Image as integer NumPy array

to_float

Image as float NumPy array

view1d

Convert image to a column view

shape

Image shape

ndim

Number of image array dimensions

Image datatype

isfloat

Image has floating point pixel values?

isint

Image has integer values?

isbool

Image has bolean values?

dtype

Datatype of image

to

Convert image datatype

astype

Cast image datatype

to_int

Image as integer NumPy array

to_float

Image as float NumPy array

cast

Cast value to same type as image

like

Convert value to the same type as image

minval

Minimum value of image datatype

maxval

Maximum value of image datatype

true

True value for logical image

false

False value for logical image

Image processing

Sub images

roi

Extract region of interest

plane

Extract plane(s) from color image

red

Extract the red plane of a color image

green

Extract the green plane of a color image

blue

Extract the blue plane of a color image

__getitem__

Extract slice of image

Color info

iscolor

Image has color pixels?

isbgr

Image has BGR color order?

isrgb

Image has RGB color order?

colororder

Set/get color order of image

colororder_str

Image color order as a string

colordict

Parse a color order specification

nplanes

Number of color planes

plane

Extract plane(s) from color image

Color

mono

Convert color image to monochrome

colorize

Colorize a greyscale image

chromaticity

Create chromaticity image

colorspace

Transform a color image between color representations

gamma_encode

Gamma encoding

gamma_decode

Gamma decoding

kmeans_color

k-means color clustering

Composition

Hstack

Horizontal concatenation of images

Vstack

Vertical concatenation of images

Tile

Tile images into a grid

Overlay

Overlay two greyscale images in different colors

Monadic functions

abs

Absolute value of image

sqrt

Square root of image

LUT

Apply lookup table

apply

Apply a function to an image

clip

Clip pixel values

roll

Roll image by row or column

normhist

Histogram normalisaton

stretch

Image normalisation

threshold

Image threshold

threshold_interactive

Interactive thresholding

threshold_adaptive

Adaptive threshold

invert

Invert image

Dyadic functions

apply2

Apply a function to two images

blend

Image blending

choose

Pixel-wise image merge

paste

Paste an image into an image

direction

Gradient direction

Linear filtering

convolve

Image convolution

smooth

Smooth image

gradients

Compute horizontal and vertical gradients

direction

Gradient direction

Harris_corner_strength

Harris corner strength image

scalespace

Compute image scalespace sequence

pyramid

Pyramidal image decomposition

canny

Canny edge detection

Non-linear filtering

window

Generalized spatial operator

zerocross

Compute zero crossing

rank

Rank filter

medianfilter

Median filter

distance_transform

Distance transform

erode

Morphological erosion

dilate

Morphological dilation

close

Morphological closing

open

Morphological opening

morph

Morphological neighbourhood processing

hitormiss

Hit or miss transform

thin

Morphological skeletonization

thin_animate

Morphological skeletonization with animation

endpoint

Find end points on a binary skeleton image

triplepoint

Find triple points

Image labeling

labels_binary

Blob labelling

labels_MSER

Blob labelling using MSER

labels_graphseg

Blob labelling using graph-based segmentation

kmeans_color

k-means color clustering

Image similarity

sad

Sum of absolute differences

ssd

Sum of squared differences

ncc

Normalised cross correlation

zsad

Zero-mean sum of absolute differences

zssd

Zero-mean sum of squared differences

zncc

Zero-mean normalized cross correlation

similarity

Locate template in image

Shape changing

trim

Trim pixels from the edges of the image

pad

Pad the edges of the image

decimate

Decimate an image

replicate

Replicate image pixels

roi

Extract region of interest

samesize

Automatic image trimming

scale

Scale an image

rotate

Rotate an image

rotate_spherical

Rotate a spherical image

warp

Image warping

warp_affine

Affine warp of image

warp_perspective

Perspective warp

interp2d

Image warping

undistort

Undistort image

view1d

Convert image to a column view

Multiview operations

stdisp

Interactive display of stereo image pair

stereo_simple

Simple stereo matching

DSI_refine

Refine disparity from disparity space image

stereo_BM

Stereo block matching

stereo_SGBM

Stereo semi-global block matching

rectify_homographies

Create rectification homographies

Binary operators

__add__

Overloaded + operator

__sub__

Overloaded - operator

__mul__

Overloaded * operator

__pow__

Overloaded ** operator

__sub__

Overloaded - operator

__truediv__

Overloaded / operator

__floordiv__

Overloaded // operator

__and__

Overloaded & operator

__or__

Overloaded | operator

__xor__

Overloaded ^ operator

__lshift__

Overloaded << operator

__rshift__

Overloaded >> operator

__eq__

Overloaded == operator

__ne__

Overloaded != operator

__gt__

Overloaded > operator

__ge__

Overloaded >= operator

__lt__

Overloaded < operator

__le__

Overloaded <= operator

Unary operators

__minus__

Overloaded unary - operator

__invert__

Overloaded ~ operator

Image feature extraction

Whole image features

hist

Image histogram

sum(*args, **kwargs)

Sum of all pixels

min(*args, **kwargs)

Minimum value of all pixels

max(*args, **kwargs)

Maximum value of all pixels

nonzero()

Find non-zero pixel values as 2D coordinates

flatnonzero()

Find non-zero pixel values as 1D indices

peak2d([npeaks, scale, interp, positive])

Find local maxima in image

otsu()

Otsu threshold selection

mean(*args, **kwargs)

Mean value of all pixels

std(*args, **kwargs)

Standard deviation of all pixels

var(*args, **kwargs)

Variance of all pixels

median(*args, **kwargs)

Median value of all pixels

stats()

Display pixel value statistics

mpq

Image moments

npq

Normalized central image moments

upq

Central image moments

moments

Image moments

humoments

Hu image moment invariants

Region features

blobs

Find and describe blobs in image

MSER

Find MSER features in image

ocr

Optical character recognition

fiducial

Find fiducial markers in image

Line features

canny

Canny edge detection

Hough

Find Hough line features

Point/corner features

SIFT

Find SIFT features in image

ORB

Find ORB features in image

BRISK

Find BRISK features in image

AKAZE

Find AKAZE features in image

Harris

Find Harris features in image

ComboFeature

Combination feature detector and descriptor

Image i/o

Read

Read image from file

disp

Display image

write

Write image to file

metadata

Get image EXIF metadata

showpixels

Display image with pixel values

anaglyph

Convert stereo images to an anaglyph image

stdisp

Interactive display of stereo image pair

Constant images

Zeros

Create image with zero value pixels

Constant

Create image with all pixels having same value

String

Create a small image from text string

Random

Create image with random pixel values

Squares

Create image containing grid of squares

Circles

Create image containing grid of circles

Ramp

Create image of linear ramps

Sin

Create image of sinusoidal intensity pattern

Graphics

draw_line

Draw line into image

draw_circle

Draw circle into image

draw_box

Draw box into image

Small example images

String

Create a small image from text string

print

Print image pixels in compact format

showpixels

Display image with pixel values