How to alter an image so noise is reduced by using a threshold within a loop

조회 수: 3 (최근 30일)
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
Image Analyst
Image Analyst 2019년 2월 26일
편집: Image Analyst 2019년 2월 26일
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"

댓글을 달려면 로그인하십시오.

채택된 답변

Niti K
Niti K 2019년 2월 26일
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.
test.JPG

추가 답변 (0개)

제품


릴리스

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by