I have a class that has a member of type Mat
. I am doing some operation on the input image parameter and saving the image after step X
in that member and returning the image after step Y
. My problem is how to do it better:
- assigning the
step X
image to the member; or - assigning the clone of
step X
image to the member?
The code is something like:
class Processing
{
private:
cv::Mat m_img;
public:
cv::Mat getTopHat() const { return m_topHat; }
cv::Mat binarization(const cv::Mat& imgIn)
{
cv::Mat img2;
processing1(imgIn, img2);
processing2(img2, img2);
m_img = img2.clone(); // or
// m_img = img2;
processing3(img2, img2);
return img2;
}
};
I am not sure if I do the second operation (assignment) is ok regarding the data. Any suggestions?