Setting pixel values behaves differently on different machines.

asked 2020-06-11 11:51:14 -0500

Malathi_72 gravatar image

I wanted to get left half, right half of image with original size. I used the code below. It works in some machine. In other the full image is cleared.

>  h, w =drimg.shape
>         limg=drimg[0:h, 0:w]
>         rimg=drimg[0:h, 0:w]
>         for j in range(h):
>             for i in range(int(w/2),w):       
>                 limg[j][i]=255
>         for j in range(h):
>             for i in range(0,int(w/2)):
                   rimg[j][i]=255
edit retag flag offensive close merge delete

Comments

In other the full image is cleared.

that's the "expected output".

btw: downvoted for: you're asking in the wrong place. python/numpy problem (slices !), not an opencv one at all

berak gravatar imageberak ( 2020-06-11 13:45:12 -0500 )edit

I may be wrong but isn't an image represented as a n- dimensional numpy array in opencv python? ^^ But slicing is python specific indeed.

holger gravatar imageholger ( 2020-06-11 19:05:38 -0500 )edit