Write a function to add random noise to an image in matlab
이전 댓글 표시
How do I create a function to add random noise without using imnoise? I am trying to figure out how to do it without using the built-in matlab functions. I know I have to add a random integer to every pixel...
function output=randomnoise(current_img)
for current_img(n)
current_img(n)=current_img(n)+ randi([-255 255],1)
n=n+1
end
This is what I am coming up with right now, but I don't think my loop is visiting each value. How do I visit each pixel and how do I add random noise to it?
댓글 수: 1
Walter Roberson
2015년 10월 9일
The distribution of random value you add to the pixel is important.
채택된 답변
추가 답변 (2개)
Walter Roberson
2015년 10월 9일
0 개 추천
Arifaa A
2019년 9월 18일
function output=randomnoise(current_img)
% Cast to double;
current_img = double(current_img);
[rows, columns] = size(current_img)
for col = 1 : columns
for row = 1 : rows
output(row, col) = current_img(row, col)+ randi([-255 255],1)
end
end
noise = randi([-255, 255], rows, columns);
output = current_img + noise;
댓글 수: 1
Image Analyst
2019년 9월 18일
How is that different than my code? It looks identical.
카테고리
도움말 센터 및 File Exchange에서 Image Arithmetic에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!