Image Thresholding in OpenCV

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey there welcome to learn open CV in this video we're going to learn about image thresholding using open CV image thresholding is used to separate object from the background where each pixel value is classified into either foreground or background based upon predefined threshold values for this open CV has a function called threshold it inputs The Source image and the threshold value as well as the max pixel Val value and the type of thresholding to perform but wait why do we have seven types of thresholding and what does each one do well let's understand them on code to follow along with me open the learn open CV blog post link from the description click on the download code Banner fill in your details and hit enter you'll receive the starter code link on your email download it and let's get started we first import open CV and read the the image make sure to read the image as gray scale this is the image we will perform thresholding on now use the function CV2 do threshold and pass the source image the threshold value Max pixel value and the threshold type let's start with thresh binary the function returns an optimal threshold value if it has been calculated and the thresholded image next display the image and and run the code any pixel value below the threshold value 130 becomes 0 and pixels above 130 become 255 the max Val if you change the max Val to say 100 the image becomes black and gray instead of black and white now let's try the next thresholding type thresh binary IV as an inverted it converts any pixel value below the threshold value to the max Val and otherwise it converts them to zero next is truncate which is given by thresh trunk if the pixel value is above the threshold value it gets truncated and other pixel values remain unchanged so max Val is not needed in this type if these concepts are difficult to grasp check out opencv University's free opencv boot camp go to open cv. org /un university/ free courses to no more next thresholding type is thresh to zero any pixel value below the threshold becomes zero and pixel values above the threshold remain unchanged Max Val is not needed here as well likewise thresh to Z ionv works the opposite any pixel value above the threshold becomes zero and remains unchanged otherwise Max Val is not needed here as well finally the last two thresholding types are thresh U and thresh triangle these use U and triangle algorithm to find the optimal threshold value which will be returned in our variable T the pixel values below the optimal threshold become zero otherwise they become Max Val so for these we need not provide the threshold value but we need to provide the max Val here are both the results side by side so that's all about image thresholding using open CV if you like this video check out the complete playlist on getting started with open CV do comment on what you would like to see next and don't forget to subscribe thanks for watching until next time
Info
Channel: LearnOpenCV
Views: 895
Rating: undefined out of 5
Keywords: Deep Learning, Artificial Intelligence, AI, ML, image processing, opencv python tutorial, opencv tutorial for beginners, opencv image fundamentals, computer vision basics, python image thresholding, otsu thresholding image processing python, thresholding digital image processing opencv, image segmentation thresholding method, image thresholding applications, image thresholding opencv python, thresholding image, thresholding in image processing python, thresholding image processing
Id: BA00xTv5-Z4
Channel Id: undefined
Length: 3min 55sec (235 seconds)
Published: Mon Feb 26 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.