sliding window

1 次查看(过去 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.

回答(3 个)

Ben Mitch
Ben Mitch 2011-5-22
I think you're after filter2(). Try
mn = filter2(ones(3), im);
  5 个评论
Gova ReDDy
Gova ReDDy 2011-6-11
danx..bt i want to store the mean value of the 3x3 sliding window in the centre pixel and the window should slide to the next 3x3 position
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
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 个评论
Gova ReDDy
Gova ReDDy 2011-6-12
Not the same actually image size is 256*256 pixels and the sliding window size is 3*3 each centre pixel value of window should have the window mean value,"the next 3*3 window " means the window should slide along all the pixels of the image.
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');

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by