While you can manipulate color images, for purposes of illustration it's much easier to work with grayscale images. They can be represented as simple rectangular matrices of numbers, which can be manipulated as mathematical objects. (Color images must be represented as matrices of red, green, and blue triplets, which are more complicated to deal with.) So, we'll start our manipulations by extracting the image data from the expression, scaling it so the values run between 0 and 1, and adding up a weighted average of the red, green, and blue components of each pixel (the weights are based on the sensitivity of the eye to each color).

Now that we have the data set as a simple two-dimensional matrix of numbers, it's easy to do all sorts of things to it. For example, if we subtract each element in it from 1, we will get an effect like a photographic negative (remember the data set is scaled to have values between 0 and 1). Note that we are making use of the fact that in *Mathematica* you can perform mathematical operations on nested lists and the operations will automatically be applied to each element. So in this example, we are in fact subtracting each element of the matrix from 1, individually.

as our kernel.

We took a matrix with 250,000 elements and convolved it with a matrix with 10,000 elements. If we count each multiplication and each addition as one operation, then it should take 20,000 operations to calculate each output pixel (10,000 multiplications and 10,000 additions). The total number of operations thus would be: