how to built mean filter without padding ?

조회 수: 4 (최근 30일)
Muhammad
Muhammad 2021년 8월 21일
댓글: DGM 2021년 8월 22일
i want this mean filter without padding and padding by replication .here in my code i have done padding with 1
a = input('Please input the matrix like "[1, 2; 3, 4]":');
% mf= ones(3,3)
% meanA = mean(A(:))
a1= padarray(a,[1 1],1)
[m n]=size(a1);
c=zeros(size(a));
for i=2:(m-1)
for j =2:(n-1)
v=a1(i-1:i+1,j-1:j+1)
vrow= v(:)'
r= median(v(:));
c(i-1,j-1)=ceil(r)
end
end
what modification do i need for this?
  댓글 수: 1
DGM
DGM 2021년 8월 22일
If you want to pad by replication, use the 'replicate' flag with padarray(). If you want to do the filtering without padding, you'll need to adjust your indexing limits accordingly, and you'll need to truncate your filter window as you operate near the image edges. Obviously, that sort of complication is why it's simpler to just use padding.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by