Raspberry Pi Computer Vision Programming by Ashwin Pajankar
Author:Ashwin Pajankar
Language: eng
Format: epub
Publisher: Packt Publishing
The output will appear as follows:
Try passing various combination of the parameters to see how the resultant image changes. In the preceding example, parallelism between the lines is preserved because of the combination of the parameters we used. You might want to try different combinations of the parameters to see that the parallelism between the lines is not preserved.
Thresholding image
Thresholding is the simplest way to segment images. Although thresholding methods and algorithms are available for colored images, it works best on grayscale images. Thresholding usually (but not always) converts grayscale images into binary images (in a binary image, each pixel can only have one of two possible values: white or black). Thresholding the image is usually the first step in many image processing applications.
The way thresholding works is very simple. We define a threshold value. For a pixel in a grayscale image, if the value of grayscale intensity is greater than the threshold, we assign a value to the pixel (for example, white), else we assign a black value to the pixel. This is the simplest form of thresholding and there are many other variations of this method, which we will see now.
In OpenCV, the cv2.threshold() function is used to threshold images. It takes as input, grayscale image, threshold value, maxVal, and threshold method as parameters, and returns the thresholded image as output. The maxVal parameter is the value assigned to the pixel if the pixel intensity is greater (or less in some methods) than the threshold. There are five threshold methods available in OpenCV; in the beginning, the simplest form of thresholding we saw is cv2.THRESH_BINARY. Let's see the mathematical representation of all the threshold methods.
Say (x,y) is the input pixel; then, operations by threshold methods are as follows:
cv2.THRESH_BINARYIf intensity(x,y) > thresh, then set intensity(x,y) = maxVal; else set intensity(x,y) = 0.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Implementing Enterprise Observability for Success by Manisha Agrawal and Karun Krishnannair(7419)
Supercharging Productivity with Trello by Brittany Joiner(6679)
Mastering Tableau 2023 - Fourth Edition by Marleen Meier(6448)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6424)
Inkscape by Example by István Szép(6297)
Visualize Complex Processes with Microsoft Visio by David J Parker & Šenaj Lelić(5992)
Build Stunning Real-time VFX with Unreal Engine 5 by Hrishikesh Andurlekar(4998)
Design Made Easy with Inkscape by Christopher Rogers(4646)
Customizing Microsoft Teams by Gopi Kondameda(4184)
Linux Device Driver Development Cookbook by Rodolfo Giometti(3940)
Business Intelligence Career Master Plan by Eduardo Chavez & Danny Moncada(3781)
Extending Microsoft Power Apps with Power Apps Component Framework by Danish Naglekar(3773)
Salesforce Platform Enterprise Architecture - Fourth Edition by Andrew Fawcett(3652)
Pandas Cookbook by Theodore Petrou(3627)
The Tableau Workshop by Sumit Gupta Sylvester Pinto Shweta Sankhe-Savale JC Gillet and Kenneth Michael Cherven(3426)
TCP IP by Todd Lammle(2995)
Drawing Shortcuts: Developing Quick Drawing Skills Using Today's Technology by Leggitt Jim(2924)
Exploring Microsoft Excel's Hidden Treasures by David Ringstrom(2895)
Applied Predictive Modeling by Max Kuhn & Kjell Johnson(2885)
