Reputation: 11
How I can to get the values of 5x5 window over image, Is there are any method to get all 25 indices for each window as int number or string form 0,0 0,1 0,2 to save it in text file over the original image?
Upvotes: 1
Views: 547
Reputation: 53029
Ok, here are a few hints to get you started. But this is basic stuff, please forgive my saying so but you should probably work through a tutorial or two.
To get a 5x5 window the straight forward way is slicing:
window = img[i:i+5, j:j+5]
here i, j
are the coordinates of your window's top left corner and should lie between 0, 0
and N-5, M-5
where NxM[x3]
is the size of your image. The x3
will be there if you have three colour channels.
To slide the window you can loop over i
and j
or use the trickery from the post I've linked to in the comments.
The indices you can get with indices
:
np.moveaxis(np.indices((5, 5)), 0, -1) + (i, j)
but saving them all seems a bit wasteful, it would suffice to store i, j, 5, 5
Upvotes: 1