Classical Machine Learning

Locate the reference pattern

BOTIE

Extract 2 by 2 windows at stride 1 and calculate each window's squared distance from the flattened reference.
Ready to test
0 passed · 0 failed · 1 not run

An empty floor. Start with the information your machine needs.

Received result

Your answer will arrive here.

Examples, experiments and workspace controls
Live values

Connect a tool's inputs to see what it produces. You can try a branch before connecting it to Result.

Try your own inputs

Change one pixel in the camera image. Can you make a different window become the best match? Inspect the distances to see whether the winner is convincing or only slightly better than another window.

Start at an output arrow, then click or drag to an input. Drag empty space to pan. Delete removes a selection. Ctrl/Cmd+Z undoes a change.
Context for this challenge

Extract 2 by 2 windows at stride 1 and calculate each window's squared distance from the flattened reference.

We are looking for a known visual pattern inside a larger image. The reference patch tells us what to look for. Let's compare it with each possible window and return the location with the smallest discrepancy, keeping the reference and the image as separate inputs.

Inspect the component calculation
Squared distances(
  Query vector: Flattened reference pixels
  Candidate rows: Slide a square window(
    Image: Camera image
    Window size: 2
    Stride: 1
  )
)
Examples and results
Flattened reference pixels
  1. 01
  2. 11
  3. 21
  4. 30
Camera image
00000
00110
00100
00000
00000
Required result
  1. 03
  2. 14
  3. 23
  4. 32
  5. 43
  6. 53
  7. 60
  8. 72
  9. 83
  10. 92
  11. 102
  12. 113
  13. 123
  14. 133
  15. 143
  16. 153
Try a fresh construction

This clears this draft, including its undo history. Earlier successful attempts stay recorded. Build again without opening hints to record an independent attempt.

Stuck? Inspect a worked construction

The tools below form one possible solution. You can assemble it, follow its signals, and undo that change to return to your own construction.

Assumptions and test precision

This is a small construction problem. The lesson explains the assumptions and the parts of the full method that this example leaves out. Numerical tests allow a difference of 0.001. Lists and structures must also have the right shape.

Your last tested pieces can start the full construction. An existing draft there keeps its own pieces.

The matching patch moves in a narrower image

This check uses the pieces from “Return the location of the least discrepant window”.

BOTIE

Predict the zero-based index of the best two-by-two patch in row-major scan order. The image now has four columns, so the number of patch positions per row has changed.
Camera image
0000
0100
0110
Flattened reference pixels
  1. 01
  2. 10
  3. 21
  4. 31

Use a number, text, or an array matching the requested result. For a matrix, put each row in brackets. Saving your prediction runs your current construction on these inputs and checks the earlier examples too.

Build a construction in the workspace above first. This case will test those pieces.

Which two inputs define a match, and why would a rotated or resized reference need more than this sliding comparison?

A matching score and its selected location depend on the representation and transformations the search permits.

This is a small construction problem. The lesson explains the assumptions and the parts of the full method that this example leaves out.

Work through the Python challenges →
Continue the courseHistogram of Oriented Gradients →
← Filters and Edges