altering matrices

need some help for matrices ...
Your program should calculate new matrices where each point consists of the average of the surrounding 8 points and itself.
x11 x12 x13
x21 x22 x23
x31 x32 x33
The new value of x22 is the average of x11…x33. For simplicity, you do not need to calculate the average for the pixels on the edge. thanks

 Respuesta aceptada

Matt Tearle
Matt Tearle el 5 de Mayo de 2011

2 votos

convn(A,B,'same')
where A is your matrix, and B is a mask that determines the weightings of points for averaging.
doc convn
for more details

5 comentarios

Sean de Wolski
Sean de Wolski el 5 de Mayo de 2011
or conv2 for this case
ben
ben el 6 de Mayo de 2011
what would be the most effective way to get the B value??
Matt Tearle
Matt Tearle el 6 de Mayo de 2011
ones (plus appropriate modifications)
Sean de Wolski
Sean de Wolski el 6 de Mayo de 2011
And to point you further in the right direction. What do you need to multiply 9 objects by before summing them to get their mean. Break down the definition of "mean".
Matt Tearle
Matt Tearle el 6 de Mayo de 2011
8, not 9, if you're not including the middle point itself. BTW, think of that as a special case of a weighted average (with no weighting on x22)...

Iniciar sesión para comentar.

Más respuestas (1)

Oleg Komarov
Oleg Komarov el 5 de Mayo de 2011

0 votos

If you have the Image Processing Toolbox use blockproc

Preguntada:

ben
el 5 de Mayo de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by