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

조회 수: 10 (최근 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 :)
  댓글 수: 2
Jan
Jan 2013년 5월 6일
This is a part of your learning, but you want us to post the required code?! I assume, "learning" implies, that you try it at least by your own.
SRIHARSHA SUSARLA
SRIHARSHA SUSARLA 2013년 5월 6일
NO dude. I meant I need to figure out how to do the whole process in MATLAB. To know the format.

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

채택된 답변

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
SRIHARSHA SUSARLA 2013년 5월 7일
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에서 Matched Filter and Ambiguity Function에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by