Feature Representations and Model Comparison
English translation
Learning objectives
Images with the same brightness may have different structures. How features are represented affects distinguishability.
Pixel representations and simple features
Starting conditions
In the 8×8 images, A has 1s only in the middle two columns, and B only in the middle two rows; all other pixels are 0.
Procedure
- Plot both images, then calculate the overall mean pixel value and the row and column sums.
- Check whether mean brightness alone distinguishes the two images, and choose one additional feature.
Results to retain
- 2 images, a feature comparison table, and a brief explanation of their representational differences.
import numpy as np
import matplotlib.pyplot as plt
A=np.zeros((8,8));B=A.copy();A[:,3:5]=1;B[3:5,:]=1
print(A.mean(),B.mean(),A.sum(axis=0),B.sum(axis=0))
Record results and self-check
Image:
Mean brightness:
Selected features:
Distinguishable:
Points to check
- Did you check that the two images have different array structures despite the same mean brightness?
Shifted Inputs
Starting conditions
Calculate the same features on images A and B shifted 1 position to the right.
Procedure
- Use
np.roll(A,1,axis=1)andnp.roll(B,1,axis=1)to shift each image one position to the right. In this example, the rightmost column wraps around to the left. - Calculate the features chosen in the previous activity, overall mean, row sums, and column sums for the shifted images too. For each image, record feature values before and after the shift side by side.
- Distinguish features that remain unchanged from those that change, and explain whether your selected features still distinguish the two images.
Results to retain
- Images before and after shifting, and a comparison table of the same features.
A2=np.roll(A,1,axis=1);B2=np.roll(B,1,axis=1)
Record results and self-check
Images before and after the shift:
Mean:
Row and column sums:
Selected features and distinguishability:
Points to check
- Did you calculate the same features before and after the shift?
Checking Other Inputs
Starting conditions
Flip one pixel in each of A and B to examine the robustness of the selected features.
Procedure
- Select one pixel in each of A and B and change 0 to 1 or 1 to 0. Record the changed row and column Index and the values before and after the change.
- Recalculate the features selected earlier, and record their values before and after the change and whether they distinguish the two images. Explain how changing one pixel affected the features.
Results to retain
- Changed pixels, features before and after the changes, and whether the images remain distinguishable.
Record results and self-check
Changed pixel Indices and values:
Features before and after the change:
Whether the two images are distinguishable:
Reasoning:
Points to check
- Did you record the positions and values of the changed pixels?