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

  1. Plot both images, then calculate the overall mean pixel value and the row and column sums.
  2. Check whether mean brightness alone distinguishes the two images, and choose one additional feature.

Results to retain

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

Shifted Inputs

Starting conditions

Calculate the same features on images A and B shifted 1 position to the right.

Procedure

  1. Use np.roll(A,1,axis=1) and np.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.
  2. 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.
  3. Distinguish features that remain unchanged from those that change, and explain whether your selected features still distinguish the two images.

Results to retain

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

Checking Other Inputs

Starting conditions

Flip one pixel in each of A and B to examine the robustness of the selected features.

Procedure

  1. 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.
  2. 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

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