From the course: Code Clinic: Ruby

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Determining the best match

Determining the best match

From the course: Code Clinic: Ruby

Start my 1-month free trial

Determining the best match

- Now that we've introduced fuzziness, we've discovered that there's the possibility that we'll either set our fuzziness too low, and miss a match that we should have had, or that we'll set it too high, and get a false positive as a result. It's a tricky thing. Therefore, what we really need is a strategy that help us determine the best match. Instead of asking whether pixels are different from each other or not, which is a true/false answer, instead we need to ask "How different are they?" and try to quantify that difference as a value. Once we can do that, then we take those differences, and we can add them up. And we could have a sum of absolute differences, or SAD, for short. We'll scan through the whole image, computing all of these different SAD values, trying to find the lowest one. The lowest SAD is going to be the least different position, and that means it's our best match. Let's see how we can do this in Ruby Code. You can see I've added a new strategy to my image-matchers…

Contents