How to create a 7 X 7 window?

7 views (last 30 days)
Sabarinathan Vadivelu
Sabarinathan Vadivelu on 27 Oct 2012
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???

Answers (3)

Wayne King
Wayne King on 27 Oct 2012
You can use blockproc() to apply some processing on blocks of a prescribed size.
  1 Comment
Sabarinathan Vadivelu
Sabarinathan Vadivelu on 27 Oct 2012
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?

Sign in to comment.


Matt J
Matt J on 27 Oct 2012
Edited: Matt J on 27 Oct 2012
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 on 27 Oct 2012
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!