Task 1

Points: 50

The Jigsaw Puzzle

During a covert operation in Sherlock Holmes’ private archives, a crucial photographic record was sabotaged. The image was broken into nine equal tiles. All the nine photographic tiles survived. But before they could be secured, an unknown adversary tampered with them:

Holmes identified a subtle but decisive clue: the top-left pixel of every tile. This pixel is a compact encoding of the tile’s original position and orientation.

The Image:

a 300×300 image containing a 3×3 grid of 100×100 pixel tiles (9 shards total). Tiles are indexed 0–8 in row-major order (refer below for the numbering layout).

The Encoded Information

The top-left pixel (row=0, col=0) of each tile encodes two values in its BGR channels:

Channel Value to be extracted What the value encodes
Red Lower Nibble Original tile index (0–8)
Green Upper Nibble Clockwise rotation that was applied to the original tile (0–3)

Rotation codes:

  • 0 → 0°
  • 1 → 90° CW
  • 2 → 180°
  • 3 → 270° CW

Your Mission: Decode each tile’s embedding and report to Sherlock with the reassembled image.

Deliverables

  1. Your code (solution.cpp) - Complete source file.
  2. restored.png - Output image generated by running the code on 1_cvshred.png.

[Submit Here]