Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use TDD with image processing algorithms?

Recently, I have worked in a project were TDD (Test Driven Development) was used. The project was a web application developed in Java and, although unit-testing web applications may not be trivial, it was possible using mocking (we have used the Mockito framework).

Now I will start a project where I will use C++ to work with image processing (mostly image segmentation) and I'm not sure whether using TDD is a good idea. The problem is that is very hard to tell whether the result of a segmentation is right or not, and the same problem applies to many other image processing algorithms.

So, what I would like to know is if someone here have successfully used TDD with image segmentation algorithms (not necessarily segmentation algorithms).

like image 388
Alceu Costa Avatar asked Aug 15 '09 23:08

Alceu Costa


People also ask

Which algorithm is used for image processing?

Marr–Hildreth algorithm: It is an early edge detection algorithm. Canny edge detector algorithm: Canny edge detector is used for detecting a wide range of edges in images. Generalized Hough transform algorithm. Hough transform algorithm.

Is TDD only for unit testing?

One Functionality, One Test: TDD is a form of Unit Test. The driven in the TDD means that to write code, you need to write the test first. And the best way to do is by focussing on only single functionality. Create a test that focuses on only one cause but sometimes one test is not enough.

Does TDD help in design process?

The correct sentence is: BDD helps the design process, whereas TDD is more suitable for integration and functional testing. BDD is known as behavioral-driven development, is the process that helps the develops to understand the coding in a simple and easy-to-understand language.


2 Answers

Whenever I do any computer-vision related development TDD is almost standard practice. You have images and something you want to measure. Step one is to hand-label a (large) subset of the images. This gives you test data. The process (for full correctness) is then to divide your test-set in two, a "development set" and a "verification set". You do repeated development cycles until your algorithm is accurate enough when applied to the development set. Then you verify the result on the veriication set (so that you're not overtraining on some weird aspect of your development set. This is test driven development at its purest.

Note that you're testing two different things when developing heavily algorithm dependent software like this.

  1. The regular bugs you'll get in your software. These can be tested using "normal" TDD techniques
  2. The performance of your algorithm, for which you need a system outlined above.

A program can be bug free according to (1) but not quite according to (2). For example, a very simple image segmentation algorithm says: "the left half of the image is one segment, the right half is another segment. This program can be made bug free according to (1) quite easily. It is another matter entirely wether it satisfies your performance needs. Don't confuse the two aspects, and don't let one interfere with the other.

More specifically, I'd advice you to develop the algorithm first, buggy warts and all, and then use TDD with the algorithm (not the code!) and perhaps other requirements of the software as specification for a separate TDDevelopment process. Doing unit tests for small temporary helper functions deep within some reasonably complex algorithm under heavy development is a waste of time and effort.

like image 22
jilles de wit Avatar answered Sep 22 '22 11:09

jilles de wit


at a minimum you can use the tests for regression testing. For example, suppose you have 5 test images for a particular segmentation algorithm. You run the 5 images through the code and manually verify the results. The results, when correct, are stored on disk somewhere, and future executions of these tests compare the generated results to the stored results.

that way, if you ever make a breaking change, you'll catch it, but more importantly you only have to go through a (correct) manual test cycle once.

like image 71
Steven A. Lowe Avatar answered Sep 19 '22 11:09

Steven A. Lowe