Python OpenCV
About Lesson

In this Python OpenCV lesson we are going to learn about Python OpenCV Image Rotation,  we can use cv2.rotate() function for rotating an image in OpenCV and there are three constant types of rotation that you can pass as parameter in the function, these are the constants.


  • cv2.ROTATE_180




This is the complete code for this lesson.




These are our three rotation types.




We want to show our all image types in matplotlib, so by this reason we need to convert our color space, as we have already said that opencv uses GBR color space, but matplotlib uses RGB color, we need to convert BGR to RGB color, for more information about color spaces you can check the color space lesson, we can use cv2.cvtColor() for converting the color spaces.



Because we are showing four types of images for that we need to use subplot from matplotlib.




Run the complete code and this is the result.

Python OpenCV Image Rotation
Python OpenCV Image Rotation



Thank you for visiting my website! If you enjoyed the free courses, please consider supporting my works on Patreon.
Exercise Files
No Attachment Found
No Attachment Found