Microsoft
Microsoft
Of course, computers don't have biological eyes that work the way ours
do, but they're capable of processing images; either from a live camera
feed or from digital photographs or videos. This ability to process images
is the key to creating software that can emulate human visual perception.
Copy
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
The array consists of seven rows and seven columns, representing the
pixel values for a 7x7 pixel image (which is known as the image's
resolution). Each pixel has a value between 0 (black) and 255 (white); with
values between these bounds representing shades of gray. The image
represented by this array looks similar to the following (magnified) image:
Copy
Red:
Green:
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
Blue:
Copy
Red: 150
Green: 0
Blue: 255
Copy
Red: 255
Green: 255
Blue: 0
Copy
-1 -1 -1
-1 8 -1
-1 -1 -1
Copy
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
First, we apply the filter kernel to the top left patch of the image,
multiplying each pixel value by the corresponding weight value in the
kernel and adding the results:
Copy
(0 x -1) + (0 x 8) + (0 x -1) +
The result (-255) becomes the first value in a new array. Then we move
the filter kernel along one pixel to the right and repeat the operation:
Copy
(0 x -1) + (0 x 8) + (0 x -1) +
Again, the result is added to the new array, which now contains two
values:
Copy
-255 -510
The process is repeated until the filter has been convolved across the
entire image, as shown in this animation:
Diagram of a filter.
The filter is convolved across the image, calculating a new array of values.
Some of the values might be outside of the 0 to 255 pixel value range, so
the values are adjusted to fit into that range. Because of the shape of the
filter, the outside edge of pixels isn't calculated, so a padding value
(usually 0) is applied. The resulting array represents a new image in which
the filter has transformed the original image. In this case, the filter has
had the effect of highlighting the edges of shapes in the image.
To see the effect of the filter more clearly, here's an example of the same
filter applied to a real image:
Because the filter is convolved across the image, this kind of image
manipulation is often referred to as convolutional filtering. The filter used
in this example is a particular type of filter (called a laplace filter) that
highlights the edges on objects in an image. There are many other kinds
of filter that you can use to create blurring, sharpening, color inversion,
and other effects.