#SciFri: Playing Snap with Snakes
Those of you that have been following me on social media will know that as part of my PhD, I’ve been busy working through some legacy data and creating a capture history for grass snakes (Natrix helvetica) at my study site. To do this, I’ve been using a couple of different software packages to first make all the images as uniform as possible and then, secondly to identify unique individuals. Due to the overwhelming interest on Twitter, I thought it would be a good idea to share some advice incase you’d like to attempt something similar!
The first step is to straighten the photos, which may be snakes but could also be newts or fish or whatever your study species is. Using Window’s own photo gallery (which differs depending which operating system you’re running) or an alternative program, rotate all the images you wish to straighten so they are facing right or as close as you can get. It’s also optional at this stage to crop your photos slightly which will make the future steps easier. When ready, open i3S Straighten (which can be downloaded here) and open your first photo within it. You’ll then be able to draw a line down the middle of the area you’d like to straighten (a), when happy you can then select the area around the line you’d like to straighten (b) and then once satisfied you can complete the straightening (c). It does take some trial and error to get the process as smooth and seamless as illustrated below and some photos may be particularly tricky to straighten. In some circumstances, images will be impossible to straighten without creating distortion in the rest of the image.
Once the image is straightened and you’ve saved the file, you will see that a file will appear in the folder with the original file called filename_str.jpg. This allows you to distinguish between the two and personally I’d delete the original files or at least keep them in a separate folder. Some of the images may have large areas of black in the corners where the straightening didn’t have enough of the original image to work with. In these instances, it’s best to fill these spots in with a neutral colour such as that of the background. This can be a bit fiddly but it’s worth it in the end as it helps to reduce any noise in the image ready for the next step. Before starting the next step, it’s best to download Wild-ID (available here) and familiarise yourself with the software.
Wild-ID is a a Java based application that is designed to match patterns within images, which makes it ideal for my study but also in other applications such as those involving giraffes or whale sharks. Before you open Wild-ID, create an empty folder within the folder containing your photos that will soon become your Wild-ID database directory. When you first open Wild-ID, it will let you set this folder as the database directory where all of the log files will be stored. Afterwards, the software will ask you select the folder containing the photos you wish to compare. These will then load in and you’ll see a value of how many unscored photos there are, depending on how many were in the folder. The next step is to click ‘Compute Scores’ and depending on the quantity of photos may take a few moments or an hour or so. I recommend in this time going off to make a cup of tea and coming back to your computer afterwards.
Once the photos have been scored, you can start to match them using the scores that Wild-ID has just given them. The most likely match will be displayed at the first image on top of the stack, of the potential 20 available to you (depending on how many you’ve entered into the database). The software won’t be able to spot every match due to factors such as poor photo quality, inconsistent position of the photo subject and shadows so take this into account when using Wild-ID. It’s a perfect piece of software but it’s not infallible. Depending on the purpose of your matching, you can make a note of the matches as you go along or check the match log at the end to then go back and rename files or make a note of which images correspond to which individuals.
There are a number of different software packages out there that rely on algorithms to match patterns in photos. I’ve found Wild-ID to be one of the quickest and easiest to use, often booting it from a USB flash drive when on the go. If you found this useful then please let me know in the comments below. I’d also like to hear from you if you’ve got any questions or you’ve managed to successfully use the software in tandem on your own project.