You must use different matrices for input and output, e.g. cvSmooth(*src, *dst, CV_MEDIAN, param1, 0);