【图像处理】MATLAB:图像噪声

本文探讨了MATLAB中图像噪声的模拟和应用,包括不同类型的噪声模型如高斯、椒盐、瑞利等。介绍了函数imnoise及其变体imnoise2和imnoise3用于产生和处理噪声,并提供了相关代码示例。文章还提到了噪声参数的估计,但部分内容未能运行成功,暂以书上图像展示。
摘要由CSDN通过智能技术生成

噪声模型

  模拟噪声的行为和影响的能力是图像复原的核心。

  采用函数imnoise来使用噪声污染一幅图像。

g = imnoise ( f , type , parameters )


噪声应用

  • 高斯噪声在诸如低照明水平图像传感器操作等情况下被用作一种近似。

  • 椒盐噪声由不完善的开关设备产生。

  • 照相乳剂中的银粒大小是用对数正态分布描述的随机变量。

  • 瑞利噪声产生于波段成像。

  • 指数和厄兰噪声在描述激光成像中的噪声方面是很有用的。


相关函数

A = rand( M , N );              % 生成M×N的数组,元素在区间(0,1)均匀分布。
A = randn( M , N );             % 生成M×N的数组,元素是零均值、单位方差的正态(高斯)数。

I = find(A);                    % 返回I中所有数组A的索引,没找到则返回一个空矩阵。
[r,c] = find(A);                % 返回矩阵A的非零元素的行和列索引。
[r,c,v] = find(A);              % 除了返回行索引和列索引,还以列向量v返回A的非零值。

I = find(A<128);                % 示例1
A(I)=0;                         % 寻找图像中值小于128的像素并把它们置零。
I = find(A>=64&A<=192);         % 示例2
A(I) = 128;                     % 将闭区间[64,192]的所有像素置为128。

使用指定的分布产生空间随机噪声(函数imnoise2)

  该函数生成一个大小为M×N的噪声数组R,不以任何形式缩放。imnoise输出一个有噪声的图像,而imnoise2产生噪声模式本身。

function R = imnoise2(type, M, N, a, b)
%IMNOISE2 Generates an array of random numbers with specified PDF.
%   R = IMNOISE2(TYPE, M, N, A, B) generates an array, R, of size
%   M-by-N, whose elements are random numbers of the specified TYPE
%   with parameters A and B. If only TYPE is included in the
%   input argument list, a  single random number of the specified
%   TYPE and default parameters shown below is generated. If only
%   TYPE, M, and N are provided, the default parameters shown below
%   are used.  If M = N = 1, IMNOISE2 generates a single random
%   number of the specified TYPE and parameters A and B.
%
%   Valid values for TYPE and parameters A and B are:
% 
%   'uniform'       Uniform random numbers in the interval (A, B).
%                   The default values are (0, 1).  
%   'gaussian'      Gaussian random numbers with mean A and standard
%                   deviation B. The default values are A = 0, B = 1.
%   'salt & pepper' Salt and pepper numbers of amplitude 0 with
%                   probability Pa = A, 
function R = imnoise2(type, varargin) %IMNOISE2 Generates an array of random numbers with specified PDF. % R = IMNOISE2(TYPE, M, N, A, B) generates an array, R, of size % M-by-N, whose elements are random numbers of the specified TYPE % with parameters A and B. If only TYPE is included in the % input argument list, a single random number of the specified % TYPE and default parameters shown below is generated. If only % TYPE, M, and N are provided, the default parameters shown below % are used. If M = N = 1, IMNOISE2 generates a single random % number of the specified TYPE and parameters A and B. % % Valid values for TYPE and parameters A and B are: % % 'uniform' Uniform random numbers in the interval (A, B). % The default values are (0, 1). % 'gaussian' Gaussian random numbers with mean A and standard % deviation B. The default values are A = 0, B = 1. % 'salt & pepper' Salt and pepper numbers of amplitude 0 with % probability Pa = A, and amplitude 1 with % probability Pb = B. The default values are Pa = % Pb = A = B = 0.05. Note that the noise has % values 0 (with probability Pa = A) and 1 (with % probability Pb = B), so scaling is necessary if % values other than 0 and 1 are required. The noise % matrix R is assigned three values. If R(x, y) = % 0, the noise at (x, y) is pepper (black). If % R(x, y) = 1, the noise at (x, y) is salt % (white). If R(x, y) = 0.5, there is no noise % assigned to coordinates (x, y). % 'lognormal' Lognormal numbers with offset A and shape % parameter B. The defaults are A = 1 and B = % 0.25. % 'rayleigh' Rayleigh noise with parameters A and B. The % default values are A = 0 and B = 1. % 'exponent
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值