2014-03-08 10:09:43 -0600 asked a question Blob extraction by colour segmentation Hello everyone, I made an application which detects objects of a set color in a webcam image. I implemented a simple segmentation using Mahalanobis distance (the said reference colour is "trained" from 10/20 images obtaining a mean vector and covariance matrix), and I obtained a binary image (a Mat in which pixel values are 255 or 0). How can I perform blob analysys using this binary image? Which classes/methods/functions can I use? I'd like, for example, to determine the size of the biggest blob and ignore smaller blobs. Thanks in advance. 2014-03-02 10:52:01 -0600 commented answer Weird problem with Mahalanobis distance function I kinda solved it by myself. One of the vectors was defined as unsigned int, and I changed that to double. 2014-03-02 07:27:38 -0600 asked a question Weird problem with Mahalanobis distance function Hello there! I'm trying to do an image segmentation based on Mahalanobis distance, but the implementation in Visual Studio with OpenCV 2.4.8 throws a weird exception I don't know how to solve. Here is the snippet: // cam_frame is a Mat object, while pixel is a std::vector made of 3 elements. // mn is a 1x3 Mat representing the mean vector, and i_covar has been successfully computed for (int i=0; i(i, j)[0]; //B component pixel[1]=cam_frame.at(i, j)[1]; //G component pixel[2]=cam_frame.at(i, j)[2]; //R component if (Mahalanobis(mn, pixel, i_cvm)(i,j)=255; else mask.at(i,j)=0; } }  The Mahalanobis function throws an exception regarding the size of the arguments, but I can't really figure out.