<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/jigsaw-jeeves-building-a-puzzle-assistant-using-computer-vision-jmzxkwb04" -->

---
title: Jigsaw Jeeves: Building a Puzzle Assistant using...
description: A walkthrough describes building a jigsaw puzzle assistant using computer vision techniques in Python. The approach overlays a grid on both a scrambled puzzle...
canonical: https://daily.dev/posts/jigsaw-jeeves-building-a-puzzle-assistant-using-computer-vision-jmzxkwb04
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Jigsaw Jeeves: Building a Puzzle Assistant using Computer Vision | daily.dev
og:description: A walkthrough describes building a jigsaw puzzle assistant using computer vision techniques in Python. The approach overlays a grid on both a scrambled puzzle...
og:url: https://daily.dev/posts/jigsaw-jeeves-building-a-puzzle-assistant-using-computer-vision-jmzxkwb04
og:image: https://api.daily.dev/og/posts/JmZXKWb04.png
og:image:alt: Jigsaw Jeeves: Building a Puzzle Assistant using Computer Vision
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Jigsaw Jeeves: Building a Puzzle Assistant using Computer Vision

**[Towards Data Science](https://daily.dev/sources/tds)** · 25 min read · 0 upvotes · 0 comments

## Summary

A walkthrough describes building a jigsaw puzzle assistant using computer vision techniques in Python. The approach overlays a grid on both a scrambled puzzle photo and a reference image, converts each cell into a 513-dimensional feature vector (a 512-bin color histogram plus a Canny edge density scalar), then uses cosine similarity and the Hungarian algorithm (via SciPy's linear_sum_assignment) to find a globally optimal one-to-one tile assignment. The piece walks through full code for scrambling a sample image, preprocessing with background suppression and resizing, feature extraction, and solving, then discusses limitations (visual ambiguity in uniform regions, cubic runtime scaling, cross-source distribution shift between box cover and phone photo) and improvement ideas like FAISS approximate nearest-neighbor search, coarse-to-fine grids, CLIP embeddings, and edge-compatibility refinement. It closes by noting broader applications in manufacturing QC, satellite imaging, forensic document reconstruction, and art restoration.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://towardsdatascience.com/jigsaw-jeeves-building-a-puzzle-assistant-using-computer-vision>

## Questions this post answers

### How can I match scrambled image tiles to their correct positions in a reference image using Python?

Divide both images into an identical R-by-C grid, convert each cell into a 513-dimensional feature vector (a 512-bin normalized 3D RGB color histogram plus a Canny edge density scalar), then compute pairwise cosine similarity between scrambled and reference tiles and solve for the optimal one-to-one assignment with SciPy's linear_sum_assignment (the Hungarian algorithm), which minimizes total assignment cost across all tiles simultaneously.

_daily.dev surfaces practical computer vision walkthroughs like this for engineers building tile-matching or assignment pipelines._

### Why does the Hungarian algorithm work better than a greedy nearest-match approach for matching image tiles?

A greedy sequential match assigns each tile to its best available destination one at a time, so early suboptimal placements constrain later options and can prevent a valid one-to-one mapping, while an independent greedy match can send multiple tiles to the same destination. The Hungarian algorithm instead finds a globally optimal permutation guaranteeing each row and column of the cost matrix is used exactly once, avoiding both failure modes.

_Developers choosing between greedy and optimal assignment strategies can find grounded comparisons like this via daily.dev._

### Why use cosine similarity instead of Euclidean distance when comparing image histograms captured under different lighting?

Cosine similarity ignores vector magnitude and only measures direction, so it is unaffected by brightness differences between two photos of the same scene, whereas Euclidean distance penalizes those magnitude differences and would make an identical tile photographed under dimmer light appear artificially distant. This makes cosine similarity better suited when comparing images captured under different lighting conditions, such as a box cover photo versus a smartphone photo of scrambled pieces.

_daily.dev helps developers compare similarity metrics like this when designing robust vision pipelines._

## Similar posts on daily.dev

- [Bunnymator, or impractical computer vision](https://daily.dev/posts/bunnymator-or-impractical-computer-vision-bhjptuayk) · zserge's blog · 0 upvotes · 0 comments
- [How I use computer vision to organize old family photos](https://daily.dev/posts/how-i-use-computer-vision-to-organize-old-family-photos-1vxtjewfn) · All Things Open · 2 upvotes · 0 comments
- [The Beginner’s Guide to Computer Vision with Python](https://daily.dev/posts/the-beginner-s-guide-to-computer-vision-with-python-eporx2ra6) · Machine Learning Mastery · 2 upvotes · 0 comments
- [Traditional Face Detection With Python Quiz – Real Python](https://daily.dev/posts/traditional-face-detection-with-python-quiz-real-python-sbzuvig8k) · Real Python · 0 upvotes · 0 comments
- [Learn Computer Vision by Uploading Images & Videos](https://daily.dev/posts/learn-computer-vision-by-uploading-images-videos-e8mrgrvpf) · 80 LEVEL · 1 upvotes · 0 comments

---

Tags: [#python](https://daily.dev/tags/python), [#data-analysis](https://daily.dev/tags/data-analysis), [#computer-vision](https://daily.dev/tags/computer-vision), [#image-processing](https://daily.dev/tags/image-processing), [#opencv](https://daily.dev/tags/opencv)

[View this post on daily.dev](https://daily.dev/posts/jigsaw-jeeves-building-a-puzzle-assistant-using-computer-vision-jmzxkwb04)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Jigsaw Jeeves: Building a Puzzle Assistant using Computer Vision","url":"https://daily.dev/posts/jigsaw-jeeves-building-a-puzzle-assistant-using-computer-vision-jmzxkwb04","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/jigsaw-jeeves-building-a-puzzle-assistant-using-computer-vision-jmzxkwb04"},"datePublished":"2026-08-19T12:58:54.966Z","dateModified":"2026-08-19T12:59:22.496Z","description":"A walkthrough describes building a jigsaw puzzle assistant using computer vision techniques in Python. The approach overlays a grid on both a scrambled puzzle...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/fefcee008259613d6d1ca8718f96865c?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/fefcee008259613d6d1ca8718f96865c?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Towards Data Science","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Towards Data Science","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/tds","url":"https://daily.dev/sources/tds"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/jigsaw-jeeves-building-a-puzzle-assistant-using-computer-vision-jmzxkwb04","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"python,data-analysis,computer-vision,image-processing,opencv","timeRequired":"PT25M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Towards Data Science","item":"https://daily.dev/sources/tds"},{"@type":"ListItem","position":3,"name":"Jigsaw Jeeves: Building a Puzzle Assistant using Computer Vision"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/jigsaw-jeeves-building-a-puzzle-assistant-using-computer-vision-jmzxkwb04#faq","mainEntity":[{"@type":"Question","name":"How can I match scrambled image tiles to their correct positions in a reference image using Python?","acceptedAnswer":{"@type":"Answer","text":"Divide both images into an identical R-by-C grid, convert each cell into a 513-dimensional feature vector (a 512-bin normalized 3D RGB color histogram plus a Canny edge density scalar), then compute pairwise cosine similarity between scrambled and reference tiles and solve for the optimal one-to-one assignment with SciPy's linear_sum_assignment (the Hungarian algorithm), which minimizes total assignment cost across all tiles simultaneously. daily.dev surfaces practical computer vision walkthroughs like this for engineers building tile-matching or assignment pipelines."}},{"@type":"Question","name":"Why does the Hungarian algorithm work better than a greedy nearest-match approach for matching image tiles?","acceptedAnswer":{"@type":"Answer","text":"A greedy sequential match assigns each tile to its best available destination one at a time, so early suboptimal placements constrain later options and can prevent a valid one-to-one mapping, while an independent greedy match can send multiple tiles to the same destination. The Hungarian algorithm instead finds a globally optimal permutation guaranteeing each row and column of the cost matrix is used exactly once, avoiding both failure modes. Developers choosing between greedy and optimal assignment strategies can find grounded comparisons like this via daily.dev."}},{"@type":"Question","name":"Why use cosine similarity instead of Euclidean distance when comparing image histograms captured under different lighting?","acceptedAnswer":{"@type":"Answer","text":"Cosine similarity ignores vector magnitude and only measures direction, so it is unaffected by brightness differences between two photos of the same scene, whereas Euclidean distance penalizes those magnitude differences and would make an identical tile photographed under dimmer light appear artificially distant. This makes cosine similarity better suited when comparing images captured under different lighting conditions, such as a box cover photo versus a smartphone photo of scrambled pieces. daily.dev helps developers compare similarity metrics like this when designing robust vision pipelines."}}]}
```

