What You Will Do:
- Explain how an image can be represented as a dataset of pixel light-intensity values.
- Analyze a digital image by treating its pixels as data and exploring how color values are distributed.
- Collect a large, representative sample of pixel values using a stratified random sample.
- Use Desmos histograms to describe the distributions of the red, green, and blue channels using shape, center, spread, and unusual features.
- Compute and compare the mean and median of each color channel to interpret skewness and connect your conclusions to what you see in the image.
- Watch this Computerphile video to learn how digital images are mathematically represented and stored in an image file. This video will provide context and meaning for this activity.
- In this activity, we use stratified sampling to collect pixel data. The image is divided into a grid, and we take the same number of samples from each section. This reduces clumping (too many samples from one area) and helps ensure the sample represents the whole image. For example, it helps avoid oversampling a large blue sky and missing other parts of the picture.
- Each pixel sample records four values: the sample index and the red, green, and blue (RGB) values. Each RGB value ranges from 0 to 255 because it is stored as an 8-bit binary number (one byte).
- The Desmos histograms show the frequency of each byte value (0 to 255) for the red, green, and blue color channels.
- Click this link Statistical Image Analysis to open the worksheet in a new browser tab. Click Make a copy to save your version to your Google Drive.
- Click the Show Directions button in the upper-right corner for directions for the activity.
Directions:
Data Collection:
- Pull down the Test Image menu below and select Normal Distribution.Click Sample Pixels button. Scroll down to view the histograms. Notice that the red, green, and blue histograms are similar in shape, centered near the middle of the scale, and roughly symmetric (close to a normal distribution). Because the three channels are balanced, the image looks like a neutral gray.
- Select Normal Red Shifted and repeat the steps above. Notice that the red histogram is shifted to higher values than the green and blue histograms. Because red values are higher on average, the image looks warmer (more reddish or tan).
- Select Normal Blue Shifted and repeat the steps above. Notice that the blue histogram is shifted to higher values than the green and red histograms. Because blue values are higher on average, the image looks cooler (more bluish).
- Select Right Skew and repeat the steps above. Notice that most values are low, with a long tail extending to the right. Because many pixels have low RGB values, the image looks darker overall, with a few brighter pixels.
- Select Left Skew and repeat the steps above. Notice that most values are high, with a long tail extending to the left. Because many pixels have high RGB values, the image looks lighter overall, with a few darker pixels.
- Select Low Kurtosis and repeat the steps above. Notice that the histogram is flatter, with values more evenly spread around the middle and fewer extreme tail values. Because the pixel values are more evenly varied, the image tends to show a more consistent, textured noise pattern with fewer very bright or very dark specks.
- Select High Kurtosis and repeat the steps above. Notice that many values cluster near the center, along with some more extreme values in the tails. Because many pixels are close to the same value, the image tends to look smoother overall, with occasional specks of very bright or very dark pixels.
- To analyze your own picture, click Open Image button and choose a jpg, png, or webp file, then click Sample Pixels.
- Click the Show Instruction button in the upper-right corner to continue the activity.
No Image Selected
Analysis:
- View the red, green, and blue histograms. Compare their shapes, including spread, skew, and peaks.
- Compute the mean of each channel in Desmos: mean(r), mean(g), and mean(b).
- Compute the median of each channel in Desmos: median(r), median(g), and median(b).
- Compute an overall brightness estimate using a simple average of the three channel means: (mean(r) + mean(g) + mean(b)) / 3
- Click Capture Graph to copy your histogram and paste it into your worksheet.
- Explore how sampling choices affect the results. Change the number of samples and the stratified sample grid size, then compare how the channel histograms change.
- Try two different images and compare their channel histograms. Which image is more colorful and why?
- Compare mean vs median for each channel. If mean is greater than median, what might that suggest about highlights? If mean is less than median, what might that suggest about shadows?
- Edit the image, or crop it, and repeat sampling. How does changing the subject change the distributions?
- Try one of the light intensity activities using an Observe light sensor in the Observe Light Sensor activities collection.