0

The view_as_image function of skimage returns windows of numpy arrays of predetermined size. For example, view_as_windows(array, (20, 96), 5) will return arrays windows of (20, 96) of the original array, sliding 5 rows at a time (if the width of the original array is also 96). I need to determine in advance how many windows will be output by skimage.

Say I have this array:

import numpy as np
from skimage.util.shape import view_as_windows

array = np.random.randint(0, 255, (128, 96))

And I get windows of (20, 96), with a stride of 5.

view_as_windows(array, (20, 96), 5)

It will yield 22 windows. Like this:

first: (0:20, :)
second: (5:25, :)
third: (10:30, :)

How can I do this, i.e. get the number of windows it will create?

Nicolas Gervais
  • 33,817
  • 13
  • 115
  • 143

0 Answers0