Search code examples
pythonarraysnumpy-slicing

I want to flip an image (with three channels RGB) horizontally just using array slicing. How can I do it with python?


I appreciate it if you can provide me with one-line code.

I used np.flip but I want a different approach to make it generalized. This was my code: np.flip(image, 1) I also used np.fliplr(image).

Note: The image to be flipped has three channels.


Solution

  • flipped_image = image[:, ::-1, :]