How to create a 7 X 7 window?

1 次查看(过去 30 天)
Sabarinathan Vadivelu
I have an image with a size of 512X512. I want to create a 7X7 window to do some operations. But want to process all the pixels?? How can I do?? Zero padding is possible???

回答(3 个)

Wayne King
Wayne King 2012-10-27
You can use blockproc() to apply some processing on blocks of a prescribed size.
  1 个评论
Sabarinathan Vadivelu
IS it possible to use for loops to get the area and process? But when using for loop, Im getting Error that Index exceeds Matrix Dimensions. How to clear it?

请先登录,再进行评论。


Matt J
Matt J 2012-10-27
编辑:Matt J 2012-10-27
If it's applicable, you could use MAT2TILES from the File Exchange, and do
A=rand(512);
B=mat2tiles(A,[7,7]);
for i=1:numel(B)
process(B{i});
end

Image Analyst
Image Analyst 2012-10-27
It depends on what you want to do. For a simple 7x7 filter window moving over by one pixel at a time, you can use conv2() or imfilter(). If you want to move in "jumps" of 7 (so that you won't have any overlapping windows) then you can use blockproc. This is probably less common than moving over a pixel at a time. Finally if you need something custom and complicated, you can use nlfilter().
What does "zero padding possible" mean? Every filter will have edge effects and sometimes you are given the opportunity to handle them in prescribed ways. If you want some kind of custom edge behavior then you'll have to write something custom.
I can help more if you define what "some operations" means. For example if you want to do something like local max, standard deviation, entropy, skeletonize, etc. there are special functions for those kinds of things. To determine if there is a routine already in the toolbox that will do what you want to do, you have to tell us what you want to do.

Community Treasure Hunt

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

Start Hunting!

Translated by