Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

how to replace a matrix element by the avearage of its surrounding elements

조회 수: 1 (최근 30일)
Al-Amin Alvi
Al-Amin Alvi 2015년 6월 15일
마감: MATLAB Answer Bot 2021년 8월 20일
1 2 3
A= 4 5 6
7 8 9
is a matrix
resultant matrix
11/3 19/5 13/3
B= 23/5 40/8 27/5
17/3 31/5 19/3

답변 (1개)

Henric Rydén
Henric Rydén 2015년 6월 15일
편집: Henric Rydén 2015년 6월 15일
A=[ ...
1 2 3 ; ...
4 5 6 ; ...
7 8 9];
kernel = [ ...
1 1 1; ...
1 0 1 ; ...
1 1 1];
neighbors = imfilter(ones(size(A)),ones(size(A)))-1;
result = imfilter(A,kernel) ./ neighbors;

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by