Creating noise in an image unconventionally
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Oliver Horrobin
el 21 de En. de 2021
Comentada: Oliver Horrobin
el 22 de En. de 2021
I have tried the imnoise funtion with my image (a gaussian beam) and none of the options seem to work. The problem is that because it fades out to very small numbers the imnoise function rounds it all to 1 and does not show what I'm looking for.
Anyways what I am looking for help with is how to make this work:
x = rand(size(Beam)); # I created a matrix the size of the image between 0 and 1
x = x<0.2; # removed 80% of the values and am left with 0's and 1's. 20% being a 1.
z = Beam+x; # added x to the beam
n = rand(size(Beam))*250 # created a matrix of random numbers between 0 and 250 the size of the beam.
# the if statement was an attempt to have it so that wherever there was a 1 in x that same value in the image would get replaced by the corresponding number in n (wherever z =x+1)
if z>Beam
Beam = n;
end
The goal is to have a random 20% (subject to change) of the image as random numbers between 0 and 250
Any help is appreciated.
Cheers,
Ollie
0 comentarios
Respuesta aceptada
Walter Roberson
el 21 de En. de 2021
x = rand(size(Beam)) < 0.2; %logical array!
z = Beam;
n = rand(1,nnz(x)) * 250;
z(x) = n;
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!