sliding window

조회 수: 8(최근 30일)
Gova ReDDy
Gova ReDDy 2011년 5월 22일
How to apply a 3x3 sliding window for an image while the pixel in the center of the window should have the mean value of the window.


Ben Mitch
Ben Mitch 2011년 5월 22일
I think you're after filter2(). Try
mn = filter2(ones(3), im);
  댓글 수: 5
Image Analyst
Image Analyst 2011년 6월 12일
But that's exactly what Ben, Jan, and Sean de's code does! Did you look up the help for filter2()? It is basically conv2() (which is highly optimized) with the 'same' option. (I always use conv2 rather than filter2.) Write a test with a small image to convince yourself.

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

Jan 2011년 6월 11일
What is "the next 3x3 position"? Will the resulting picture have a width and size reduced by 3? If so, this can achieve the calculation efficiently: FEX: BlockMean
  댓글 수: 2
Image Analyst
Image Analyst 2011년 6월 12일
Patan, how many times do we have to say it. CONV2 AND IMFILTER WILL DO WHAT YOU'RE ASKING!!!!

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

Sean de Wolski
Sean de Wolski 2011년 5월 25일
Imean_window = conv2(double(I),ones(3)/9,'valid');


Find more on Get Started with MATLAB in Help Center and File Exchange


Community Treasure Hunt

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

Start Hunting!

Translated by