-2

So I just red here on Stackoverflow that you can select every Nth row and column of an array by doing:

image[0::N, 0::N]

which made me wonder since "normal" indexing is done by:

image[x][y]

Please explain why in the first example it is done via a comma between the indexes and in the second example by two separate brackets?

The array image is created via:

image = skipy.misc.imread('image.png', flatten=True)

I'd also appreciate a link to a page where I can inform myself further on this

Alon
  • 434
  • 4
  • 19
  • Did you read the [NumPy docs](https://docs.scipy.org/doc/numpy-1.12.0/reference/arrays.indexing.html) and [Explain Python's slice notation](https://stackoverflow.com/questions/509211/explain-pythons-slice-notation)? – blacksite Jun 03 '17 at 12:57
  • That's great thank you! I haven't had a key-word which I could google to find the proper information but slice notation it is! – Alon Jun 03 '17 at 12:59
  • 1
    The comma doesn't work on a Python list. That syntax is used on Numpy arrays. – PM 2Ring Jun 03 '17 at 13:01

1 Answers1

0

You can use comma separator in Numpy arrays - https://docs.scipy.org/doc/numpy-1.12.0/reference/arrays.indexing.html

Separate brackets would work for Numpy arrays as well

Jakub Dvorak
  • 163
  • 1
  • 1
  • 5