|
|
图像泊松噪声是没法控制大小的,泊松噪声是和你图像亮度挂钩的,图像越亮,泊松噪声就近似高斯分布了,图像越暗,其影响越严重,因此单论一张图来说,控制其泊松噪声的大小是没有意义的。
如果你非要改变泊松噪声,可以有如下代码
function [ b ] = poisson_fun( a,lamda )
sizeA = size(a);
a = double(a( );
% (Monte-Carlo Rejection Method) Ref. Numerical
% Recipes in C, 2nd Edition, Press, Teukolsky,
% Vetterling, Flannery (Cambridge Press)
b = zeros(size(a),'like', a);
idx1 = find(a<50); % Cases where pixel intensities are less than 50 units
if (~isempty(idx1))
g = exp(-a(idx1)*lamda);
em = -ones(size(g));
t = ones(size(g));
idx2 = (1:length(idx1))';
while ~isempty(idx2)
em(idx2) = em(idx2) + 1;
t(idx2) = t(idx2) .* rand(size(idx2));
idx2 = idx2(t(idx2) > g(idx2));
end
b(idx1) = em;
end
% For large pixel intensities the Poisson pdf becomes
% very similar to a Gaussian pdf of mean and of variance
% equal to the local pixel intensities. Ref. Mathematical Methods
% of Physics, 2nd Edition, Mathews, Walker (Addison Wesley)
idx1 = find(a >= 50); % Cases where pixel intensities are at least 50 units
if (~isempty(idx1))
b(idx1) = round(a(idx1) + sqrt(lamda*a(idx1)) .* randn(size(idx1)));
end
b =uint8(reshape(b,sizeA));
end |
|