Grayscale Logic
Draw on the canvas to understand how images are represented as matrices and apply basic filters.
Draw on the canvas to understand how images are represented as matrices and apply basic filters.
From visual drawings to numerical matrices—the foundation of computer vision.
At its core, a digital grayscale image is nothing more than a grid of numbers—a matrix. Each number, called a pixel, represents the brightness at that specific point, typically ranging from 0 (black) to 255 (white). This interactive bridges the gap between the visual image you draw and the underlying numerical data that a computer actually "sees" and manipulates.
The most fundamental concept in all of computer vision is that images are just data. Every operation, from a simple filter to a complex neural network, is a mathematical function performed on this matrix of pixel values. By understanding this relationship, you unlock the ability to understand how image processing algorithms work.
As you draw on the canvas, you are directly changing the numbers in the matrix on the right. A bright stroke sets pixel values to 255, while the empty canvas is all zeros. Every filter you apply is just a rule that transforms these numbers.
Draw a simple diagonal line on the canvas. Watch the corresponding cells in the matrix light up with values like 255, 120, and 80. Notice how the "brush" has a soft edge, creating intermediate gray values, not just pure white.
Click the Invert Colors button. Observe the matrix. Every pixel value `p` has been replaced by `255 - p`. The black background (0) becomes white (255), and your white drawing (255) becomes black (0). This is a simple but powerful pixel-wise operation.
Draw a shape and then click Apply Threshold with the slider at 128. All pixels with a value greater than 128 become pure white (255), and all others become pure black (0). This is called binarization, and it's a common step to simplify an image and isolate objects of interest.
Clear the canvas and draw a single, sharp dot. Now click Gaussian Blur. Look at the matrix. The single high-value pixel has been "spread out" to its neighbors, creating a smooth gradient. This is achieved by averaging each pixel with its surrounding pixels, which is essential for reducing noise in images.
Draw a solid square. Click Edge Detection. Notice that only the borders of your square remain as bright pixels in the matrix. The solid interior becomes black (0). This filter calculates the difference between neighboring pixels; where the difference is large (at an edge), the output value is high.
Mastering this fundamental concept—that images are just grids of numbers—is the key to understanding all of computer vision.
At its core, a digital grayscale image is nothing more than a grid of numbers—a matrix. Each number, called a pixel, represents the brightness at that specific point, typically ranging from 0 (black) to 255 (white). This interactive bridges the gap between the visual image you draw and the underlying numerical data that a computer actually "sees" and manipulates.