Needle In Haystack Search

Kevin FOO
2 min readAug 30, 2021

--

In my previous article “Jigsaw Search In Image”, the naming I used still sort of confusing. Lets use the famous phrase of searching for a needle in the haystack.

In the previous version, searching for a needle in the haystack took almost 11 seconds for a small 360x360 image, it will be worse if I tried to search for a thumbnail in a bigger resolution image.

I managed to enhance it to search for four corners of the needle in the haystack and later verify the results pixels by pixels. By doing this, the time taken to search for the needle reduced drastically.

To make comparison fair, I’ll be reusing the same images I used from the previous article.

a.png
c.png
d.png
v2
v1

The new v2 takes less than 1 seconds to find the needle as compared to the old v1 took more than 7 seconds.

v2
v1

As for searching for the needle that is not found in the haystack, the reduction of time required is huge as it no longer uses the dumb, brute force search.

< Back to all the stories I had written

--

--

Kevin FOO
Kevin FOO

Written by Kevin FOO

A software engineer, a rock climbing, inline skating enthusiast, a husband, a father.

No responses yet