Photo Pattern Matcher
Find a template patch inside an uploaded photo using normalized cross-correlation.
About this tool
Find a small template in a photo. Drop or paste photo and template, or open Template from photo and enter original-pixel x/y/width/height. Select region allows dragging; tiny clicks do not crop. Preview shows the current template. Find matches starts the search, progress counts tested positions, Cancel stops it. Demo restores example images without running automatically.
Centered normalized cross-correlation subtracts template and local patch means, then divides their dot product by both centered norms. Scores −1…+1: +1 same structure, 0 no correlation, −1 inverted brightness. Positive linear brightness/contrast changes preserve scores, not probabilities. Constant templates are rejected; constant windows are excluded even with negative thresholds. Tiny variance is treated as numerically constant.
Both images use the same nominal downscale: photo ≤512 px, template ≤128 px on longest side, with further joint reduction to ≤40 million pixel-pair comparisons. Captions show original → search dimensions. Integer rounding/resampling can vary; an imported template must show the object at its original photo scale, not an independently fitted size. Transparency on white, grayscale (0.299R+0.587G+0.114B)/255. PNG/JPEG/WebP/GIF/BMP ≤5 MiB/16 MP/16,384 px per side; decoded GIF frame frozen, no animation search. Photo-derived crops are sampled from the already resized photo, keeping their pixel alignment; external templates with different subpixel alignment or fine texture can score lower after resampling.
Minimum score −1…1, Match limit 1–20; after searching these filters reuse the score map. Rectangle suppression removes candidates with intersection/union >0.3 against a stronger selected match, ties by y then x. Nonoverlapping neighbors can remain. Box numbers correspond to table rows. Upper-left coordinates rounded in original pixels; CSV preserves unrounded coordinates, box sizes, scores, threshold and original/search dimensions. Crops use original pixels; dragged selection is quantized to the search grid.
Optional heatmap: one pixel per tested upper-left position, fixed black −1/gray 0/white +1; constant windows transparent. Smaller than photo because template remains fully inside. Image/crop changes clear results; invalid files retain the last image, stale asynchronous responses discarded. No rotation, multiscale detection, semantic recognition or color comparison. Downscaling loses detail; floating point/resampling limit precision. Inspect edge cases independently.
Only input values are remembered in this browser. Calculated results and experiment histories are not saved.