int rows = UndistortImage.rows; 把这个代码改成matlab语言
时间: 2023-05-23 14:05:06 浏览: 52
UndistortImage = imread('image_filename');
[rows,cols,channels] = size(UndistortImage); % 获取图像行数、列数和通道数
相关问题
将下面代码写成matlab形式 float cal_psnr(const Mat x, const Mat y) { float RMS = 0; for (int i = 0; i < x.rows; i++) { const float* Mx = x.ptr<float>(i); const float* My = y.ptr<float>(i); for (int j = 0; j < x.cols; j++) { RMS += (My[j] - Mx[j]) * (My[j] - Mx[j]); } } RMS = sqrtf(RMS / (x.rows * x.cols)); return 20 * log10f(255.0 / RMS); }
function psnr = cal_psnr(x, y)
RMS = 0;
for i = 1:x.rows
Mx = x(i,:);
My = y(i,:);
for j = 1:x.cols
RMS = RMS + (My(j) - Mx(j)) * (My(j) - Mx(j));
end
end
RMS = sqrt(RMS / (x.rows * x.cols));
psnr = 20 * log10(255.0 / RMS);
end
将下面代码写成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]; } } }
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
相关推荐
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)