1 | initial version |
there's a couple of things you can do
blurring ( sounds counterintuitive, but if that's the first step you do, even before the binarizing, you'll filter out all the bubbles, noize, etc )
e.g. blur(img,img,Size(5,5));
try something else for binarizing. if the contrast between the fish and the surrounding is high enough, you don't actually need an Edge filter like Canny or Sobel, but a simple threshold will work much nicer. Edge filters tend to break the contours into small pieces, also every line has an inner and an outer edge then.
e.g. threshold(img,img,128,255,0);