Ask Your Question

Revision history [back]

Combined replies that led to the solution of this problem.

First a summation of the hints leading up to the solution:

  1. If you apply findContours, you retrieve a list of points. An irregular shape will probably have way more points since the border variance is larger. Try it out? As to color, that will only work if the lighting conditions are controlled.
  2. What you could do now, only if your fishes have a large contrast to the algea is for each contour look at all the inner pixels and do some measurements in them. Specifying average color values for example could be used with a simple classifier to decide if it is a fish or not.
  3. If you go into color spaces like HSV or Lab you could easily avoid the large influence of lighting variations.
  4. There should be a way of describing how smooth the edge contours of your objects are. There is way more variation in your plants then in your fish contour. What you could also do is use movement. An algae will stay aproximately static in subsequent frames, while a fish will move around. This could be a fast way to ignore static regions.
  5. Yeah they do move, but their movement is in a stationary region, while the fish can swim around in the image. The algae is somewhere connected to the ground right?

The solution that was implemented:

Well I do this in my spare time so basically programming code for others I do not do nor do I encourage it. Feel free to give it a try and report back with results and problems. I will hapily look into them. I suggest trying something like:

  • Detect the x and y center position of each object
  • Keep a list of lets say 15 frames.
  • Check the variance on the x and y coordinates over these frames
  • Define a threshold, if it is higher, then it is a fish and you keep the detection, if not all detections in that area are due to the algae and you do not visualize detections there anymore.