Effacer les filtres
Effacer les filtres

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

5 vues (au cours des 30 derniers jours)
Ynne
Ynne le 25 Déc 2017
Commenté : Ynne le 25 Déc 2017
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 ?

Réponse acceptée

Image Analyst
Image Analyst le 25 Déc 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 commentaires
Image Analyst
Image Analyst le 25 Déc 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 le 25 Déc 2017
Name Size Bytes Class Attributes
correlogram 64x1 512 double

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by