Azzera filtri
Azzera filtri

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

5 visualizzazioni (ultimi 30 giorni)
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 ?

Risposta accettata

Image Analyst
Image Analyst il 25 Dic 2017
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 Commenti
Image Analyst
Image Analyst il 25 Dic 2017
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 il 25 Dic 2017
Name Size Bytes Class Attributes
correlogram 64x1 512 double

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by