フィルターのクリア

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

5 ビュー (過去 30 日間)
Ynne
Ynne 2017 年 12 月 25 日
コメント済み: Ynne 2017 年 12 月 25 日
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?
Ynne
Ynne 2017 年 12 月 25 日
Name Size Bytes Class Attributes
correlogram 64x1 512 double

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by