Fixed self-assignment in cv::Ptr::operator =

A self-assignment leads to a call of release() with refcount being 2. In the release() method, refcount is decremented and then successfully checked for being 1. As a consequence, the underlying data is released. To prevent this, we test for a self-assignment
Merge pull request #3058 from PhilLab:patch-2
fix bug 3733 for imgproc/filter.cpp
Merge pull request #3076 from vpisarev:fix_small_filters