0

I'm trying to switch to python from matlab and i have this problem.

imgMosaic is a an numpy array. You can see down there that the file resolution is 2548 x 4000 i'm trying to access the first "mini-image" (resolution 28 x 40) from imgMosaic, but i'm getting a file with resolution 28x4000 instead of 28x40 and i don't understand why.

imgMosaic = np.asarray(cv2.imread('../data/images/image.jpeg', cv2.IMREAD_COLOR))
print imgMosaic.shape
>> (2548, 4000, 3)
print imgMosaic[0:28][0:40][:]
>> (28, 4000, 3)
2
  • 2
    Use comma separated indexing : imgMosaic[0:28,0:40,:] Commented Oct 21, 2017 at 9:14
  • Thanks very much. That was the problem. Commented Oct 21, 2017 at 9:17

1 Answer 1

1

Your indexing could be modified as:

imgMosaic[:28, :40, :]

First 28 row element, first 40 column elements and all elements in the last axis.

imgMosaic[:28, :40, :].shape
>>> (28,40,3)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.