
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10476 Articles for Python

216 Views
In this program, we will read or load an image using the pillow library. The pillow library consists of a method called Image.open(). This function takes the file path or the name of the file as a string. To display the image, we use another function show(). It does not require any parameter.Example Codefrom PIL import Image im = Image.open('testimage.jpg') im.show()Output

14K+ Views
First, we can create a scatter for different data points using the scatter method, and then, we can plot the lines using the plot method.StepsCreate a new figure, or activate an existing figure with figure size(4, 3), using figure() method.Add an axis to the current figure and make it the current axes, create x using plt.axes().Draw scatter points using scatter() method.Draw line using ax.plot() method.Set the X-axis label using plt.xlabel() method.Set the Y-axis label using plt.ylabel() method.To show the plot, use plt.show() method.Exampleimport random import matplotlib.pyplot as plt plt.figure(figsize=(4, 3)) ax = plt.axes() ax.scatter([random.randint(1, 1000) % 50 for i ... Read More

9K+ Views
First, we can create bars using plt.bar and using xticks. Then, we can align the labels by setting the “vertical” or “horizontal” attributes in the “rotation” key.StepsMake lists, bars_heights, and bars_label, with numbers.Make a bar plot using bar() method, with bars_heights and length of bars_label.Get or set the current tick locations and labels of the X-axis, using xticks() with rotation='vertical' and bars_label.To show the plot, use plt.show() method.Examplefrom matplotlib import pyplot as plt bars_heights = [14, 8, 10] bars_label = ["A label", "B label", "C label"] plt.bar(range(len(bars_label)), bars_heights) plt.xticks(range(len(bars_label)), bars_label, rotation='vertical') plt.show()OutputRead More

784 Views
In this program, we will detect contours in an image. Contours can be explained simply as a curve joining all the continuous points having the same color or intensity. The contours are a useful tool for shape analysis and object detection and recognition.Original ImageAlgorithmStep 1: Import OpenCV. Step 2: Import matplotlib. Step 3: Read the image. Step 4: Convert the image from bgr2rgb. Step 5: Convert the rgb image to grayscale. Step 4: Perform thresholding on the image. Step 5: Find contours on the image. Step 6: Draw contours on the image. Step 7: Display the output.Example Codeimport cv2 import ... Read More

2K+ Views
In this program, we will find the edges in an image using the pillow library. The FIND_EDGES function in the ImageFilter class helps us to find the edges in our image.Original ImageAlgorithmStep 1: Import Image and ImageFilter from Pillow. Step 2: Open the image. Step 3: Call the filter function and specify the find_edges function. Step 4: Display the output.Example Codefrom PIL import Image, ImageFilter im = Image.open('testimage.jpg') im = im.filter(ImageFilter.FIND_EDGES) im.show()Output

311 Views
In this program, we will perform inverse zero thresholding on an image using openCV. Thresholding is a process in which the value of each pixel is changed in relation to a threshold value. The pixel is given a certain value if it is less than the threshold and some other value if it is greater than the threshold. In inverse zero thresholding, pixels having intensity value greater than the threshold value are set to 0.Original ImageAlgorithmStep 1: Import cv2. Step 2: Define the threshold and max_val. Step 3: Pass these parameters in the cv2.threshold value and specify the type of ... Read More

594 Views
In this program, we will perform zero thresholding on an image using openCV. Thresholding is a process in which the value of each pixel is changed in relation to a threshold value. The pixel is given a certain value if it is less than the threshold and some other value if it is greater than the threshold. In zero thresholding, pixels having intensity value less than the threshold value are set to 0.Original ImageAlgorithmStep 1: Import cv2. Step 2: Define the threshold and max_val. Step 3: Pass these parameters in the cv2.threshold value and specify the type of thresholding you ... Read More

984 Views
In this program, we will perform truncate thresholding on an image using openCV. Thresholding is a process in which the value of each pixel is changed in relation to a threshold value.The pixel is given a certain value if it is less than the threshold and some other value if it is greater than the threshold. In truncate thresholding, values greater than the threshold are reduced to the threshold value. Every other pixel remains the same.Original ImageAlgorithmStep 1: Import cv2. Step 2: Define threshold and max_val. Step 3: Pass these parameters in the cv2.threshold value and specify the type of ... Read More

2K+ Views
In this program, we will perform inverse binary thresholding on an image using openCV. Thresholding is a process in which the value of each pixel is changed in relation to a threshold value.The pixel is given a certain value if it is less than the threshold and some other value if it is greater than the threshold. In inverse binary thresholding, if the value of the pixel is less than the threshold, it will be given a maximum value i.e. white. If it is greater than the threshold, it will be assigned 0, i.e., black.Original ImageAlgorithmStep 1: Import cv2. Step ... Read More

762 Views
In this program, we will perform binary thresholding on an image using openCV.Thresholding is a process in which the value of each pixel is changed in relation to a threshold value. The pixel is given a certain value if it is less than the threshold and some other value if it is greater than the threshold. In binary thresholding, if the value of the pixel is less than the threshold, it will be given a 0 value, i.e., black. If it is greater than the threshold, it will be assigned 255, i.e., white.Original ImageAlgorithmStep 1: Import cv2. Step 2: Define ... Read More