Search code examples
python-3.xcrop

Can someone please explain what this statement does to the image? image = image[60:-25, 0:, 0:]


I'm trying to crop an image before applying CNN. I do not understand the above method of cropping. I understand that it is attempting to crop the image but do not understand the negative value.


Solution

  • This looks like NumPy advanced indexing, where you specify the indices for each axis, separated by commas. As for the negative, when indexing in Python a negative number indicates the index starts from the end and not the beginning. So, 60:-25 means starting from index 60 and ending 25 indices from the end.