How do we write a MATLAB code that applies a rectangular moving average window to some random image that is on our computer?

1 次查看(过去 30 天)
I need the MATLAB code for a rectangular moving average window for an image that is in my computer. It is a part of the my self learning :)

采纳的回答

Image Analyst
Image Analyst 2013-5-6
Try this:
blurredImage = conv2(yourImage, ones(windowSize));
You'll get a few errors if you have a uint8 image or color image, but they should be easy to figure out. Let me know if you can't.
  2 个评论
SRIHARSHA SUSARLA
So, if have a grayscale image to which i have to apply the rectangular moving average window filter,with variable width of say 0,5,10 etc, normalizing total integral to 1, how should i approach the problem right from basic. I ask this question since I am new to MATLAB totally, and I am required to do this as a part of hobby project. So, if you can give me a detailed explaination, it would be greatly appreciated :) Thank you.
Image Analyst
Image Analyst 2013-5-7
Use this code:
blurredImage = conv2(yourImage, ones(windowSize)/windowSize^2);
to do a moving average while keeping the same average intensity. Using windowSize^2 will normalize it so that the mean stays the same.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by