用matlab实现:1. 直方图规定化 对图像tire.tif进行规定直方图的变换,通过实验,得出什么结论。 2. 代数运算 通过求平均值降噪。 要求:选择一幅图像(如rice.tif),通过Matlab的imnoise函数对图像人为加入噪声,然后将对多幅加入噪声的图像求平均值,得到去噪的目的。
时间: 2024-02-13 20:02:42 浏览: 117
1. 直方图规定化
首先,我们需要读取并显示原始图像:
```matlab
tire = imread('tire.tif');
imshow(tire);
```
接着,我们需要获取原始图像的直方图,并绘制出来:
```matlab
tire_hist = imhist(tire);
figure;
plot(tire_hist);
```
然后,我们需要定义一个目标直方图,这里我们选择一个标准的均衡直方图:
```matlab
target_hist = histeq(tire);
```
接下来,我们可以使用`histeq`函数将原始图像规定化为目标直方图:
```matlab
tire_eq = histeq(tire, target_hist);
```
最后,我们可以将原始图像、规定化后的图像以及目标直方图显示出来进行比较:
```matlab
figure;
subplot(1,3,1);
imshow(tire);
title('Original Image');
subplot(1,3,2);
imshow(tire_eq);
title('Equalized Image');
subplot(1,3,3);
imshow(target_hist);
title('Target Histogram');
```
通过实验,我们可以得出结论:直方图规定化可以将原始图像的直方图变换为任意指定的目标直方图,从而达到改善图像对比度和亮度的效果。
2. 代数运算
首先,我们需要读取并显示原始图像:
```matlab
rice = imread('rice.tif');
imshow(rice);
```
接着,我们可以使用`imnoise`函数加入高斯噪声:
```matlab
noise_img1 = imnoise(rice, 'gaussian', 0, 0.01);
noise_img2 = imnoise(rice, 'gaussian', 0, 0.01);
noise_img3 = imnoise(rice, 'gaussian', 0, 0.01);
```
然后,我们可以将加噪后的三幅图像求平均值:
```matlab
denoise_img = (double(noise_img1) + double(noise_img2) + double(noise_img3)) / 3;
```
最后,我们可以将原始图像、加噪后的三幅图像以及去噪后的图像显示出来进行比较:
```matlab
figure;
subplot(2,2,1);
imshow(rice);
title('Original Image');
subplot(2,2,2);
imshow(noise_img1);
title('Noisy Image 1');
subplot(2,2,3);
imshow(noise_img2);
title('Noisy Image 2');
subplot(2,2,4);
imshow(denoise_img, []);
title('Denoised Image');
```
通过实验,我们可以得出结论:通过求平均值来降噪可以有效地去除高斯噪声,从而提高图像的质量。
阅读全文
相关推荐


















