How to alter an image so noise is reduced by using a threshold within a loop
1 view (last 30 days)
Show older comments
So if we want a for loop to go pixel by pixel in an image we have created or defined and change it IN RELATION to its neighbors, what should we do?
for example, if the pixel value (between 0 and 255) is <0, and if two or fewer of its neighbors are also <0, we would like to change the value to 0. Otherwise, we want to leave it as is.
1 Comment
Image Analyst
on 26 Feb 2019
Edited: Image Analyst
on 26 Feb 2019
It sounds like you have an Answer since you've accepted the one below (though I don't know how it solves your question), but if the pixel value is "between 0 and 255" then how can it ever be "<0"???
And why do you think you need a loop for this? And what would it loop over? Intensities? Pixel locations? What is your loop index - what does it represent: gray level or rows and columns?
Are you trying to describe the "sigma filter"
Accepted Answer
Niti K
on 26 Feb 2019
One way would be to define a windowsize (2 in your case) and have your for loops go from 1:size-Windows.
you can add an if condition such that if adjacent pixels surrounding the pixel in question are less than zero, you can assign that pixel value 0.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!