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.

Matching exact pixels

Matching exact pixels

From the course: Code Clinic: Ruby

Start my 1-month free trial

Matching exact pixels

- Now that we have our project set up and our image matcher class defined, we're ready to start testing out different strategies. Remember the advice I gave you earlier. "Walk before you run." You're gonna learn a lot along the way and you won't fall flat on your face your first time out. Let's begin with a strategy to match the pixels exactly. And let's also start by using lower resolution png files. There are two png files inside the images directory. Haystack dot png and needle dot png. We can see them here. Haystack dot png is this image of a parrot, it's at 72 dpi or dots per inch, that's pixels per inch, and that's much lower resolution than the 300 dpi jpeg of a parrot we'll be working with later. And then needle dot png is just a cropped version of that. So the idea is that we're looking for the needle inside the haystack so it should be able to identify the eye of the parrot right here in the image. That would indicate a successful match for us. Let's look at our first…

Contents