how can I replace the zeros in the image?
3 ビュー (過去 30 日間)
古いコメントを表示
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?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/151256/image.jpeg)
0 件のコメント
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Image Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!