Convert BGR and RGB with Python - OpenCV Last Updated : 03 Jan, 2023 Comments Improve Suggest changes Like Article Like Report Prerequisites: OpenCV OpenCV is a huge open-source library for computer vision, machine learning, and image processing. OpenCV supports a wide variety of programming languages like Python, C++, Java, etc. It can process images and videos to identify objects, faces, or even the handwriting of a human. In this article, we will convert a BGR image to RGB with python and OpenCV. OpenCV uses BGR image format. So, when we read an image using cv2.imread() it interprets in BGR format by default. We can use cvtColor() method to convert a BGR image to RGB and vice-versa. Syntax: cv2.cvtColor(code) Parameter: cv2.COLOR_BGR2RGB - BGR image is converted to RGB.cv2.COLOR_RGB2BGR - RGB image is converted to BGR. Converting a BGR image to RGB and vice versa can have several reasons, one of them being that several image processing libraries have different pixel orderings. ApproachImport moduleRead imageConvert it using cvtColor()Add wait keyAdd destroy window mechanism Image used: Apple First, we will display the image as it is imported which means in BGR format. Example: Python3 import cv2 image = cv2.imread("/content/gfg.jpeg") cv2.imshow('image',image) cv2.waitKey(0) cv2.destroyAllWindows() Output: Now to convert BGR to RGB implementation is given below. Example: Python3 import cv2 image = cv2.imread("/content/gfg.jpeg") # converting BGR to RGB image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) cv2.imshow('image', image_rgb) cv2.waitKey(0) cv2.destroyAllWindows() Output: Comment More infoAdvertise with us Next Article Convert BGR and RGB with Python - OpenCV S soumibardhan10 Follow Improve Article Tags : Python OpenCV Python-OpenCV Practice Tags : python Similar Reads Python | OpenCV BGR color palette with trackbars OpenCV is a library of programming functions mainly aimed at real-time computer vision. In this article, Let's create a window which will contain RGB color palette with track bars. By moving the trackbars the value of RGB Colors will change b/w 0 to 255. So using the same, we can find the color with 2 min read Splitting and Merging Channels with Python-OpenCV In this article, we will learn how to split a multi-channel image into separate channels and combine those separate channels into a multi-channel image using OpenCV in Python. To do this, we use cv2.split() and cv2.merge() functions respectively. Image Used: Splitting Channels cv2.split() is used 2 min read Automatic color correction with OpenCV and Python Colour correction is an important aspect of image processing and is used to correct any colour imbalances in an image. OpenCV is an open-source library for computer vision and image processing tasks that provides several functions and tools to analyze and manipulate images. In this tutorial, we will 3 min read Getting Started with Python OpenCV Computer Vision is one of the techniques from which we can understand images and videos and can extract information from them. It is a subset of artificial intelligence that collects information from digital images or videos. Python OpenCV is the most popular computer vision library. By using it, o 15+ min read Change RGB image color with HSV values with Python OpenCV An open-source library of Python, OpenCV is mainly used for image and video processing. On the other hand, there is also open source Python Library NumPy, short for Numerical Python, which works with large arrays. In this article, we will show you How we can Change RGB image color with HSV values wi 3 min read Like