I am not able to find example code of imnoise function of matlab using 'localvar' anywhere. Can anyone help me, as i am having really hard time to locate it?? As per matlab documentation, J = imnoise(I,'localvar',V) adds zero-mean, Gaussian white noise of local variance, V, to the image I. V is an array of the same size as I.
Do you mean something like this:
clc;
close all; clear all;
A = imread('peppers.png');
B = imnoise(A,'localvar',0.05*rand(size(A)));
imshow(B)
which gives this:
EDIT: Using the additional input parameters image_intensity
and var
, here is what you can get:
C = imnoise(A,'localvar',rand(1,100),rand(1,100));
The result is the following:
Moreover, you can specify a liner relationship between the variance and the image intensity, for example, by defining the variables like so:
image_intensity = rand(1,100);
var = ones(1,100); % variance is linearly proportional to image intensity.
which outputs this:
Of course you can play around as much as you like with the parameters; just be careful in defining the vectors image_intensity
and var
since their lengths must match.