Tuesday , September 17 2024

Machine Learning

Arithmetic Operations on Images using OpenCV

10 Arithmetic Operations on Images using OpenCV Arithmetic Operations on Images using OpenCV¶Arithmetic Operations like Addition, Subtraction, and Bitwise Operations(AND, OR, NOT, XOR) can be applied to the input images Addition Subtraction Bitwise operations are used in image manipulation and used for extracting essential parts in the image. In this …

Read More »

Visualizing the Different Color Channels of an RGB Image in Python using OpenCV

9 Visualizing the different color channels of an RGB image. Visualizing the Different Color Channels of an RGB Image in Python using OpenCV¶ In [2]: import cv2 img = cv2.imread('ocv2.png',1) cv2.imshow('Machine Learning',img) cv2.waitKey(0) cv2.destroyAllWindows() In [3]: import cv2 img=cv2.imread("ocv2.png",1) B, G, R = cv2.split(img) print(B) print(G) print(R) [[255 255 255 ... 255 …

Read More »

Displaying text on Image in Python using OpenCV

8 Displaying Text on Image <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS_HTML"></script> <!-- MathJax configuration --> <script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [ ['$','$'], ["\\(","\\)"] ], displayMath: [ ['$$','$$'], ["\\[","\\]"] ], processEscapes: true, processEnvironments: true }, // Center justify equations in code and markdown cells. Elsewhere // we use CSS to left justify single line …

Read More »

Drawing a Rectangle on Image in Python using OpenCV

7 Drawing a Rectangle Drawing a Rectangle on Image in Python using OpenCV¶ In [2]: import cv2 img = cv2.imread('machinelearning.png',1) cv2.imshow('Machine Learning',img) cv2.waitKey(0) cv2.destroyAllWindows() Drawing a Rectangle¶rectangle() function take 5 Arguments Image Top-left corner co-ordinates Bottom-right corner co-ordinates Color (in BGR format) Line width In [3]: import cv2 img = cv2.imread('machinelearning.png',1) output …

Read More »

Rotate the Image in Python using OpenCV

6 Rotating the Image Rotate the Image in Python using OpenCV¶ In [2]: import cv2 img = cv2.imread('machinelearning.png',1) cv2.imshow('Machine Learning',img) cv2.waitKey(0) cv2.destroyAllWindows() Rotating the Image¶There are a lot of steps involved in rotating an image. The 2 main functions used here are – getRotationMatrix2D() warpAffine() getRotationMatrix2D() : It takes 3 arguments …

Read More »

Resizing the Image in Python using OpenCV

5 Resizing the Image Resizing the Image in Python using OpenCV¶ In [2]: import cv2 img = cv2.imread('machinelearning.png',cv2.IMREAD_COLOR) cv2.imshow('Machine Learning',img) cv2.waitKey(0) cv2.destroyAllWindows() Resize image to 200px 180px ( Width Height )¶ In [3]: import cv2 img = cv2.imread('machinelearning.png',cv2.IMREAD_COLOR) resize = cv2.resize(img, (200, 180)) cv2.imshow('Machine Learning',resize) cv2.waitKey(0) cv2.destroyAllWindows()

Read More »

Extracting the Image Region of Interest (ROI) in Python using OpenCV

4 Extracting the Region of Interest (ROI) Extracting the Image Region of Interest (ROI) in Python using OpenCV¶ Read Actual Image¶ In [2]: import cv2 img = cv2.imread('machinelearning.png',1) cv2.imshow('Machine Learning',img) cv2.waitKey(0) cv2.destroyAllWindows() Read Image from Height 100-200 Pixel and Width 200-400 Pixel¶ In [3]: import cv2 img = cv2.imread('machinelearning.png',1) roi = img[100 …

Read More »

Extracting The Image RGB Values of a Pixel in Python Using OpenCV

3 Extracting the RGB values of a pixel Extracting The Image RGB Values of a Pixel in Python Using OpenCV¶ In [2]: import cv2 img = cv2.imread('machinelearning.png',1) cv2.imshow('Machine Learning',img) cv2.waitKey(0) cv2.destroyAllWindows() Get RGB Value of a Single Pixel¶ In [3]: img[100,100] Out[3]: array([203, 190, 84], dtype=uint8) In [4]: B,G,R = img[100,100] print(B,G,R) 203 …

Read More »

Introduction to OpenCV Python Tutorials

1 Introduction to OpenCV Introduction to OpenCV Python Tutorials¶Getting Started with OpenCV-Python OpenCV is a huge open-source library for computer vision, machine learning, and image processing. It can process images and videos to identify objects, faces, or even the handwriting of a human. OpenCV was started at Intel in 1999 …

Read More »