필터 지우기
필터 지우기

how can I replace the zeros in the image?

조회 수: 3 (최근 30일)
payman khayree
payman khayree 2015년 6월 16일
댓글: payman khayree 2015년 6월 18일
I want to replace the zero valued pixels inside the object with the average of their non-zeros neighbours. whats the best way doing that?

채택된 답변

Image Analyst
Image Analyst 2015년 6월 16일
That's similar to what I do with my salt and pepper denoising program (attached) - I replace with the median.
To get the average, you'd use conv2() instead of medfilt2(). You'd have to replace the zero pixels with nan's and then see if conv2() will work if there are nan's in the image. If so, do
grayImage(grayImage == 0) = nan;
blurredImage = conv2(grayImage, ones(5)/25, 'same');
% Replace nan's with average
badPixels = isnan(grayImage);
grayImage(badPixels) = blurredImage(badPixels);
  댓글 수: 3
Image Analyst
Image Analyst 2015년 6월 18일
You're welcome. Are we done then? If so, please mark as Accepted.
payman khayree
payman khayree 2015년 6월 18일
thanks

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by