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.

The current error can be reproduced by executing the following statements:
```cpp
cv::Ptr<cv::Mat> a(new cv::Mat(5,5, CV_8UC3));
a->setTo(100);
a = a;
cv::imshow("test", *a);
```