Python
Image Thresholding in OpenCV
There are various type of thresholding. We will discuss one by one: Simple Thresholding If pixel value less then threshold value then it is assigned one value else we will assign another value. For thresholding we will use cv2.threshold function. In this function we will pass four parameters: 1: Source image: Source image should be …
NumPy Math functions
Addition of NumPy array import numpy as np n1 = np.array([10, 20])n2 = np.array([30, 40]) np.sum([n1, n2])Output = 100 We can also add only column or row using axis parameter. np.sum([n1, n2], axis = 0)Output: array([30, 40]) np.sum([n1, n2], axis = 1)Output: array([30, 70]) How to calculate Mean of numPy array? import numpy as npn1 …
NumPy in Python
Numpy is numerical library of python. Numpy used for numerical and scientific computing NumPy is a multidimensional array and a collection of routines for processing those arrays. We can work with multidimensions x,y and z axis. We have some methods in numPy library using this we can process multidimensional array.
Python Functions ( lambda function, map function, filter function)
Function is a block of code which performs specific task. How to call a function What is lambda function? Lambda function is anonymous function. No function name when we use lambda function. Lambda function has many argument but we can define only single expressions. To define a lambda function we will use lambda keyword. Lambda …
Python Functions ( lambda function, map function, filter function) Read More »
Flow control statement in Python
If and else statement in Python If we need to add some conditional statement then we will use if, else conditions. Loops in Python While Loop While loop executes statement repeatedly until condition is true. For Loop For loop iterate our sequence. Sequence is a list, tuple, dictionary. For is the basic keyword like other …
Data Structures in Python
In python their are four types of basic data structures Tuple Tuple is an ordered collection of elements enclosed within brackets. Tuples are immutable. List List is an ordered collection of elements enclosed within []. Lists are mutable. Dictionary Dictionary is an unordered collection of key-values pairs enclosed with {}. Dictionary is mutable. Set Set …
How to crop an image in OpenCV using Python
It is very easy to crop image in open CV import cv2 img = cv2.imread(“crop.png”) crop_img = img[y:y+h, x:x+w] cv2.imshow(“cropped”, crop_img) cv2.waitKey(0) We need to import open CV library. Then read image using imread function. Pass cropping coordinates x,y,w,h . Print image using imshow function.
How to convert image to text using OCR?
Yes, it is possible. We can extract text from images with the help of Tesseract OCR library. Let’s start how can we do this? Below code extract text from the above images: Output: “Word count writing mistakes plagiarism Check Now” Firstly we need to add Tesseract-OCR library in our system. Create a new Python file …