In this article we will follow the tenets of TDD for developing Scientific Software as laid out in the first installment of this series to develop an edge detection filter known as the Sobel filter.
In the first article, we talked about how important — and tricky — it can be to develop reliable testing methods for software which the complex problems often found in scientific software. We also saw how to overcome those issues by following a development cycle inspired by TDD, but adapted for scientific computing. I reproduce a shortened version of these instructions below.
Implementation cycle
- Gather requirements
- Sketch the design
- Implement initial tests
- Implement your alpha version
- Build an oracle library
- Revisit tests
- Implement profiling
Optimization cycle
- Optimize
- Reimplement
New method cycle
- Implement new method
- Validate against previous curated oracles
Getting Started: The Sobel Filter
In this article, we will follow the above instructions to develop a function which applies the Sobel filter. The Sobel filter is a commonly used computer vision tool to detect or enhance edges in images. Keep reading to see some examples!