Borrar filtros
Borrar filtros

how can I replace the zeros in the image?

3 visualizaciones (últimos 30 días)
payman khayree
payman khayree el 16 de Jun. de 2015
Comentada: payman khayree el 18 de Jun. de 2015
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?

Respuesta aceptada

Image Analyst
Image Analyst el 16 de Jun. de 2015
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 comentarios
Image Analyst
Image Analyst el 18 de Jun. de 2015
You're welcome. Are we done then? If so, please mark as Accepted.
payman khayree
payman khayree el 18 de Jun. de 2015
thanks

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by