Items

Items are containers for data. An Image holds an image, and Keypoints holds point coordinates. Call a transform with tfm(item) and use itemdata to unwrap the result.

Why wrap data in an item?

For one, the item structs may contain metadata that is useful for some transformations. More importantly, though, by wrapping data in an item type, the meaning of the data is separated from the representation, that is, the concrete type.

An Array{Integer, 2} could represent an image, but also a multi-class segmentation mask. Is Array{Float32, 3} a 3-dimensional image or a 2-dimensional image with the color channels expanded?

Separating the representation from the data's meaning resolves those ambiguities.

Spatial items

Spatial items represent images, segmentation masks, keypoints, and bounding boxes.

  • Image{N, T} represents an N-dimensional image. T refers to the element type of the array that Image wraps, usually a color. When projecting images, proper interpolation methods are used to reduce artifacts like aliasing.

  • MaskBinary{N} and MaskMulti{N, T} likewise represent N-dimensional segmentation masks. Unlike images, nearest-neighbor interpolation is used for projecting masks.

  • Keypoints{N} represents landmarks as an array of SVector{N}. BoundingBox and Polygon wrap keypoints to represent a single box or polygon. These items use array dimension order, so points are (y, x) in 2D.

  • BoundingBoxes holds a collection of 2D boxes and optional labels. Each column of its coordinate matrix holds one box in (x, y) order. Use box_convert to switch between corner, corner-and-size, and center-and-size coordinates.

Spatial items have spatial bounds, which projective transformations use. The Gallery shows how to apply transformations to images and keypoints together.

Other items

Visualizing items

showitems visualizes spatial items, and showgrid arranges the visualizations of many items in a grid. The Gallery uses both throughout.

Use showitems((image, mask)) to check alignment after a transformation. Set maskalpha to adjust the default opacity of 0.5 and maskbackground to skip a label such as 1 for a multiclass mask or false for a binary mask. showgrid accepts the same options for grids of image and mask pairs.

To define your own item, see Defining items.