How to apply an 9x9 average filter to image with some boundary options?

12 views (last 30 days)
Hi! I know how to apply an average filter, but how to apply it with a certain boundary options?
For example: boundary option: X=0 or periodic?
Thank you in advance! I'm trying to learn Matlab by myself and this could be very useful for me!

Answers (2)

Image Analyst
Image Analyst on 19 Oct 2015
You can use imfilter() or conv2():
out = conv2(double(grayImage), ones(9)/81, 'same');
This assumes zeros outside the image. I can't think of any reason why you'd need a periodic situation.
  1 Comment
Lachezar Petkov
Lachezar Petkov on 19 Oct 2015
I'm trying to solve a several questions from the textbook. It says to use imfilter. I read the help file, but I did not see where I put the boundaries?
The questions ask for: X=0, X=225, mirror-reflection, periodic, equal to nearest border value.
I thought if I understand the periodic and x=0 boundary with imfilter I could sort out the rest.

Sign in to comment.


Walter Roberson
Walter Roberson on 19 Oct 2015
  1 Comment
Image Analyst
Image Analyst on 19 Oct 2015
Too bad it doesn't have a "mask-shrinking" option. I think that would be more like what people would want rather than symmetric.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!