Stripey Squares

Year: 2014 Authors: Kelly Delp

Core claim

Image matrices, when squared and rescaled, tend to become striped because repeated multiplication drives columns toward the dominant Perron-Frobenius eigenvector.

Topics

image matrices, matrix powers, Perron-Frobenius theorem, visualization

Domains

linear algebra, eigenvalues and eigenvectors, matrix diagonalization, digital image art, visualization

Methods

matrix rescaling, eigenvector analysis, diagonalization, Mathematica

Media

black-and-white images, JPEGs, Mathematica notebook

Paper text

The text below is the locally extracted OCR/Markdown version of the paper. Raw PDF files remain local and are not published here.

Proceedings of Bridges 2014: Mathematics, Music, Art, Architecture, Culture

Stripey Squares

Kelly Delp

Ithaca College

Ithaca, NY 14850, USA

kelly.delp@gmail.com

Abstract

A black and white image can be represented by a matrix containing numbers between 0 and 1; we describe a way to visualize the squares of these image matrices, and more generally any non-negative power. The squares all share a common feature, stripes, and we explain the mathematics behind these.

Introduction

This paper grew out of explorations in a Linear Algebra course. Most exercises found in a typical Linear Algebra textbook require students to work with matrices of size , where each dimension is at most 6. Images provide good examples of objects that can be represented by large matrices. A black and white photo can be represented by an array of numbers between 0 (black) and 1 (white). One can ask, what does the sum of two images look like? Of course, when we add two image matrices together, the maximum value of the sum is likely greater than one. Averaging the entries gives a way to visualize the sum. Figure 1 contains an image which illustrates this (c), as well as some intermediate linear combinations (b and d).

img-0.jpeg (a) O

img-1.jpeg (b)

img-2.jpeg (c)

img-3.jpeg (d)

img-4.jpeg (e) K Figure 1: Linear Combinations

After addition, the next operation studied by students is multiplication. A natural question arises.

Question 1. What does the square of an image look like?

We will give one potential answer to this question, and then look at more general powers of images.

Images of Squares

Suppose is an matrix corresponding to a black and white image. Since all of the entries in are non-negative, will also have all non-negative entries. Also, since the value of any entry in is at most 1, the maximum entry in is less than or equal to . To create an image matrix we must rescale the values of so that they all fall between 0 and 1. Let denote the maximum value of the entries in . Any increasing function could be applied to the entires of the matrix to create an image, with different functions creating different effects. For the purposes of this paper, we will use the linear rescaling

Delp

function, . Simply put, whenever we have a matrix with non-negative values, some of which may be greater than one, we divide every entry in the matrix by the maximum entry in that matrix.

Experimenting with several images, we see that squares of image matrices all share similar characteristics—they are “stripey”. Figure 2 contains examples of squares of portraits. Despite being very different from the original images, some of the features, such as eyes, mouths and mustaches, seem to contribute to the square image.

img-5.jpeg (a) E

img-6.jpeg (b) O

img-7.jpeg (c) J

img-8.jpeg (d) K

img-9.jpeg (e)

img-10.jpeg (f)

img-11.jpeg (g)

img-12.jpeg (h) Figure 2: Squares

The image squares suggest the question: “Where do the stripes come from?” Although only portraits are shown above, we’ll argue that any image obtained by squaring will be striped. For evidence, consider the random matrix and its square in Figure 3.

img-13.jpeg (a) random matrix Figure 3: Randomness and order

img-14.jpeg (b) random matrix squared

The stripes in the squared image are a consequence of the Perron-Frobenius theorem, which is a statement about the eigenvalues and eigenvectors of positive matrices. Theorem 1 contains one version of the Perron-Frobenius theorem, which can be found in many linear algebra texts. See [1] for example. A positive

Stripey Squares

matrix is one in which all entries are real and positive. Matrices corresponding to the images can always be represented by positive matrices. Recall that a vector is an eigenvector of , with corresponding eigenvalue , if .

Theorem 1 (Perron-Frobenius). Let be a square positive matrix. Then has a real eigenvalue with the following properties:

  1. \lambda_1 > 0
  2. has a corresponding positive eigenvector, which is unique up to scale.
  3. If is any other eigenvalue of , then |\lambda| < \lambda_1 .

We will sometimes refer to the Perron-Frobenius eigenvalue (eigenvector) as the dominant eigenvalue (eigenvector). Before discussing the stripe effect, we will consider a matrix of smaller dimension and discuss a consequence of Theorem 1.

The largest eigenvalue of this matrix is 5, and is the corresponding eigenvector. Every vector in the positive octant of can be projected (by rescaling) into the larger triangle shown in Figure 4, which is defined by the intersection of the plane defined by and the positive octant. The specific plane into which we are projecting is not important; this plane was chosen for visualization purposes. The important point is to think of vectors in this octant up to positive scale factors.

The point shown in Figure 4 corresponds to the eigenvector . Since is the dominant eigenvector, for any vector in with positive entries, applying to pulls closer to the direction of . In other words, after projecting into the plane , the point is closer to . In Figure 4 we show two triangles; the larger triangle is defined by the standard basis vectors , and . The smaller triangle, , is the (projected) image of the larger triangle after applying the matrix . The entire large triangle is mapped into the smaller one, which contains the eigenvector .

img-15.jpeg Figure 4: Action of on

Now let’s return to an image matrix . For context, we note that all of the examples shown in this paper have resolution between and . Since all of the entries in the matrix are positive, the Perron-Frobenius theorem tells us the largest eigenvalue is a positive real number, and the corresponding eigenvector has all positive entries as well. Suppose , where denotes the

Delp

column vector of . We may think of as

As in the three dimensional case, for any of the columns , the vector lies closer to the direction of the eigenvector . So, after rescaling by the maximum value of , the column vector of which corresponds to has values which are very close to the rescaled eigenvector . Therefore, all of the column vectors of the rescaled are very similar, creating the horizontal stripes in the square image.

The vertical stripes can similarly be explained. Let denote a row of , then row of is given by . Let be the left eigenvector of corresponding to the largest eigenvalue. (Note that the left eigenvectors of a matrix are equal to the eigenvectors of the transpose of .) After rescaling, all the rows of are close to the rescaled vector , creating the vertical stripes.

img-16.jpeg (a) F

img-17.jpeg (b) Matrix with the dominant eigenvector of in every row

img-18.jpeg (c) Matrix with the dominant eigenvector of in every column Figure 5: Matrices of an eigenvector

img-19.jpeg (d)

The above discussion is best illustrated with pictures. Figure 5a contains an image of this author appreciating a work by artist Parastou Forouhar, taken in the Queensland Gallery of Modern Art in Brisbane, Australia. Let denote the corresponding image matrix. Figure 5d contains an image created from . In 5c we show the image corresponding to the matrix that has the rescaled Perron-Frobenius eigenvector of in every column. Compare to and we see the eigenvector coincides with the horizontal stripes in the square matrix. The image in 5b is from the matrix which has the (rescaled) Perron-Frobenius eigenvector of in every row, which clearly corresponds to the vertical stripes.

A natural question arises: What does the cube (or higher power) of an image matrix look like? The answer is that not very much interesting happens after the square. Essentially, the sequence of rescaled power matrices converges to the rescaled product of the matrices found in Figure 5c and 5b, each of which contains a single eigenvector repeated. The convergence happens very quickly. This is evident from how closely the eigenvector matrices agree with the square image illustrated in Figure 5. It’s almost impossible to detect with the naked eye the difference in even the “square” image and the limiting product matrix. All of the higher powers also produce images that look like the image found in 5d.

Visualizing subgroups of

For any integer , the set of matrices with entries in a field F and non-zero determinant forms a group called the general linear group, . If this group is also a manifold of dimension . In the introduction we described a way to interpolate between two matrices; this interpolation (Figure 1) can be thought of as a straight line in the group , with start and end points giving the matrices for the original images. In this section we’ll describe a way to visualize another sort of path in these large dimensional (Lie) groups.

Let be a diagonalizable matrix, so were is a matrix containing the eigenvectors of , and is the matrix containing the eigenvalues of on the diagonal. Using the diagonalization we may define non-integer powers of by , where is a diagonal matrix containing the power of the eigenvalues. For diagonalizable matrices, defines a one-parameter subgroup of . We will describe a way to visualize a path in this subgroup when is a matrix corresponding to an image, the results of which are shown in Figure 6.

The matrix that we begin with comes from the image found in Figure 6i. Although this matrix is not diagonalizable over , it is diagonalizable over the complex numbers. (Thus far every image matrix we have checked has been diagonalizable over .) Therefore for non-integer values of , the matrix has complex numbers. To create the images found in Figure 6, we take the norm of all the entries in , and then use the same normalization (divide by the max value of the matrix) to create an image. For we get the identity matrix, and is the previously discussed square.

This is just one way to visualize the matrices with complex values. Another method we have tried with reasonable success uses color; for each complex entry in the matrix we assign the real part of a entry with a value on the red spectrum, and the complex part a green value. It’s interesting to see where the numbers with the largest imaginary values appear and disappear along the paths and .

Methods and Conclusions

All of the images in this paper were created in Mathematica, which has built-in support for image processing. For example, it is possible to “drag and drop” jpegs into a Mathematica notebook and immediately start manipulating. The ease with which one can turn matrices into images makes us hopeful that these tools can be used by undergraduates (with little to no programming knowledge) for class projects and exploration.

The mathematics used to explain the striped effect that occurs in the image can be found in a typical undergraduate linear algebra class. However, this author thinks it is unlikely that she would have predicted the effect. The images illuminated the mathematics, giving a nice illustration of the Perron-Frobenius Theorem.

References

Delp

img-20.jpeg (a)

img-21.jpeg (b)

img-22.jpeg (c)

img-23.jpeg (d)

img-24.jpeg (e)

img-25.jpeg (f)

img-26.jpeg (g)

img-27.jpeg (h)

img-28.jpeg (i)

img-29.jpeg (j)

img-30.jpeg (k)

img-31.jpeg (1)

img-32.jpeg (m)

img-33.jpeg (a) Figure 6: for

img-34.jpeg (o)

img-35.jpeg (p)

0 items under this folder.