Here is a version of MATLAB, somewhat equivalent to @belisarius :
I = double(imread('http://i.stack.imgur.com/sedZH.png')); BW = im2bw(I,graythresh(I)); BW = imerode(BW,strel('square',2*3+1)); BW = imfilter(BW, fspecial('average',10)); BW = imdilate(BW,strel('square',2*3+1)); BW = imcomplement(BW); imshow(BW)

source share