Topological Data Analysis

ReadImageFile
ReadImageFile("file.png",n)

Inputs an image file ("file.png", "file.eps", "file.bmp" etc) and an integer n between 0 and 765. It returns a 1/0 integer matrix representing a black/white version of the image determined by the threshold n.
WriteImageFile
WriteImageFile(A,"filename","ext")

Inputs a 1/0 matrix A, and a filename followed by its extension (e.g. "myfile" followed by "png"). A black/white image is saved to the file.

ViewMatrix
ViewMatrix(A)
ViewMatrix(A,"mozilla");

Inputs a 1/0 matrix A, and command such as "mozilla" for viewing image files. A black/white image is displayed.
BettiNumbersOfMatrix
BettiNumbersOfMatrix(A)

Inputs a 1/0 integer matrix A representing a black/white version of an image. It returns a list [b0,b1] where b0 is the zeroth betti number of the black image space, and b1 is the first betti number. All higher betti numbers will be zero as the space is 2-dimensional.
MatrixToChainComplex
MatrixToChainComplex(A)

Inputs a 1/0 integer matrix A representing a black/white version of an image and returns the cellular chain complex of the black image space (in characteristic 0).

ContractMatrix
ContractMatrix(A)

Inputs a 1/0 integer matrix A representing a black/white version of an image and modifies A so that it represents a homotopy equivalent image space hopefully with fewer black cells. Black cells are removed from the image to produce a homotopy equivalent image from which no further black cell can be removed without changing the homotopy type. The function returns true if it succeeds in reducing the number of cells of the original image; otherwise it returns false.

BoundaryOfMatrix
BoundaryOfMatrix(A)

Inputs a 1/0 integer matrix A representing a black/white version of an image. It returns a matrix representing the boundary of the black image.

SingularityMatrix
SingularityMatrix(A)

Inputs a 1/0 integer matrix A representing a black/white version of an image. It returns a matrix representing the set of points where the boundary of the black image is not differentiable. (The method for deciding differentiability at a point is crude/discrete and prone to errors.) The zeroth betti number of the set of points is a measure of the number of "corners" in the boundary of the image.

ThickenedMatrix
ThickenedMatrix(A)
ThickenedMatrix(A,n)

Inputs a 1/0 integer matrix A and returns a 1/0 matrix B. If an entry in A is equal to 1 then the corresponding entry in B and all eight neighbouring entries in B are equal to 1.

If a positive integer n is input as a second argument then the thickening process is repeated n times.

ComplementedMatrix
ComplementedMatrix(A)

Inputs a 1/0 integer matrix A and returns a 1/0 matrix B. An entry in B is equal to 1 precisely when the corresponding entry in A equals 0.