将下面代码写成matlab形式void addGuassianNoise(const int sigma, const Mat origin, Mat& noisy) { Mat noise(origin.size(), CV_32FC1); randn(noise, Scalar::all(0), Scalar::all(sigma)); for (int i = 0; i < noise.rows; i++) { const float* Mx = origin.ptr<float>(i); float* Mn = noise.ptr<float>(i); float* My = noisy.ptr<float>(i); for (int j = 0; j < origin.cols; j++) { My[j] = Mx[j] + Mn[j]; } } }
时间: 2023-12-06 12:43:46 浏览: 68
深入const int *p与int * const p的区别详解(常量指针与指向常量的指针)
5星 · 资源好评率100%
function addGuassianNoise(sigma, origin)
noisy = zeros(size(origin));
noise = normrnd(0, sigma, size(origin));
for i = 1:size(noise,1)
Mx = origin(i,:);
Mn = noise(i,:);
My = noisy(i,:);
for j = 1:size(noise,2)
My(j) = Mx(j) + Mn(j);
end
end
end
阅读全文