How to pick a sliding window of pixels arround a pixel ?

3 次查看(过去 30 天)
Hi, I used the following loop to select at each iteration a window of 5x5 pixels around a pixel of a given image 'im' in this case:
for ii=3:size(im,1)-2
for jj=3:size(im,2)-2
win=im(ii-2:ii+2,jj-2:jj+2);
end
end
How do i change it to enlarge the window to 32x32 ?

采纳的回答

Image Analyst
Image Analyst 2017-12-25
Change the 2 to 15 and 16. Note that usually window sizes are an odd number so that the filter does not create a half pixel shift in the output image. Because your size is not odd, that's why you have to subtract 15 but add 16, or vice versa, instead of the same number for each direction.
And, why don't you use nlfilter(), like in my attached demo, which handles all of that for you?
  5 个评论
Image Analyst
Image Analyst 2017-12-25
correlagram may not have 64 elements.
After you get it, set a breakpoint there and execute this line
>> whos correlogram
What does it say?

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by