Add a medianBlur to remove speckles on the mask, add some comments