how to select neighbouring 5 pixels of an image

1 visualización (últimos 30 días)
Elysi Cochin
Elysi Cochin el 23 de Abr. de 2019
Comentada: Walter Roberson el 24 de Abr. de 2019
I wanted to take one pixel from an image say im(x,y)
then take the neighbouring 5 pixels of position im(x,y)
find the maximum value of the 5 pixels and save it in maxIm(x,y)
please can someone help me write the code - i also want to do it for all the pixels in the image, so that i get maxIm the same size as im
(5 must be 4-neighbourhood pixels, including the center pixel)

Respuesta aceptada

Walter Roberson
Walter Roberson el 23 de Abr. de 2019
imdilate(YourImage, ones(11,11) )
The 11 is determined as "5 pixels in each direction relative to the center pixel".
It is plausible that you might want ones(5,5) instead, in which case the neighbourhood would be
*****
*****
**C**
*****
*****
where C marks the center pixel.
Your question is ambiguous about what the 5 means.
  6 comentarios
Elysi Cochin
Elysi Cochin el 24 de Abr. de 2019
No, not a vector, must be a single value
Walter Roberson
Walter Roberson el 24 de Abr. de 2019
YourMatrix./imdilate(YourMatrix, [0 1 0;1 1 1;0 1 0])

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by