Demo Lecture-Image Processing-Computer Vision With Generative AI Bootcamp With Doubts Solving
Key Takeaways
Demonstrates Image Processing using Computer Vision with Generative AI
Full Transcript
hello all my name is Krish naak and welcome to my YouTube channel so guys uh recently as you all know uh I had actually announced two amazing live boot camps uh one was with respect to computer vision with generative Ai and one was with respect to Advanced NLP with generative AI now in this specific video many people were also asking Kish please can you upload some of the demo videos uh with respect to the session that is currently going on so considering this particular request in this specific video video I have uploaded a recent live session complete live session of 4 hours and over here uh our Mentor who who is specifically for computer vision that is monal will be taking this entire session uh this will just give you an idea like how the flow of the entire session actually happens uh when do we take the doubt clearing how do we take the doubt clearing how do we explain from basic terms Tod Advanced terms everything is basically uh shown in this particular video in this video we are going to talk about image processing which is a super important critical aspects whenever we Pro probably discuss about computer version right so uh yes please make sure that you watch this video till the end see the flow see the content how it is probably explained each and everything over there and do let me know in the comment section whether did you like it or not additionally uh if you also want to check out the courses the courses link will be given in the description of this particular video so let's go ahead and check it out thank you so again welcome to image processing part two in part one we have talked about basic uh things about how to save images how to load images what is p Library what is open CV library right but here uh in previous class because there are beginner also I want to talk about the software weuse and where it where it fits in the production pipeline or in the pipeline where we are experimenting okay so the first thing I will talk about is talk about uh the software that we use okay let me I only want to Che I will only talk about software uh which requires software pipe um how can I say yeah let's talk about soft first and then we will start okay yes overvie of before session no that will take a lot of time okay we will talk about um different color spaces like HSV in depth we will talk about some other color spaces which is light and others okay so we will talk about more color space today more color space today also we were talking about thresholding image thresholding color thresholding so let's mention it as color thresholding okay that is that and then we will talk about Contours okay then we will talk about some image argumentation technique you can say so we will talk about image rotate shift and other things so let's mention argumentation okay and today hopefully we will be covering all of these five topics so that we can cover our manage processing and start convolution Neal network from next class okay is everyone clear about today's agenda everyone please mention yes okay okay clear and ready so let's start let's start so this is very important uh whoever is like new or experienced experienced people might know but if you don't know uh just see the screen okay so let's talk about the software which we use okay daily or in production or tomorrow you will be using that so one of the software that we uh use frequently is terminal okay terminal is where we write command terminal is where we write command okay there are different types of terminal CMD for Apple user it can be zsh you can also see git bash command line terminal when we install git okay this will give you Linux kind of envirment in Windows as well if you install git bash in your windows you will be able to see a command line kind of interface like Linux okay so this is the terminal folder for Today class I will also mention as detection also required yes yes okay yes power shell is also but we don't usually use power cell Power Cell use for like if you want to operate good in the operating system but I'm talking about in general okay CMD Zs git bash and others Powers shell is also one of that so let me write power shell power shell so what it does it can execute your command Okay suppose you have a python file sitting in some directory D colon then there is some folder F1 inside folder F1 you have f1.1 f1.2 F 1.3 then you have folder F2 here and then you have multiple folders of this file so suppose you are sitting in this part okay what you will do from the command the First Command you will do is move to the folder and inside your folder you can run whatever your script is okay your py file you can run suppose it is sitting in folder f1.2 inside a directory so what you how you can do achieve with this with any command prompt you will go to that folder and then you will use command like python then that py file so what you're running you're running a script okay and what is the required you require command prompt and also you require python installed on that system right a python installed on your system so this is what you can do with terminal okay change directory okay okay W is a tool okay I will I will check W so this is uh what the terminal does what is a notepad notepad is just a plain editor okay it helps us write programs okay it helps us write and edit program or any text in any extension okay suppose it is a txt file you just writing no notes it is a python file you're writing python but it does not have a flexibility of debug it does not have a flexibility of debugging it or running it okay you cannot run you can just edit WR and uh this one okay now comes suppose vs code vs code is a editor but now it is a IDE as well that is integrated development envirment integrated development environment okay so it means you'll be able to write edit and then run as well okay write edit run and debug as well also it provides multi language support because it is a IDE and vs code has a very good community community means People Like Us suppose uh there is already a python extension in the VSS code and we want to contribute it to be able to include ml directly to be able to uh do an NLP directly okay so what we will do we will write code for vs code and we'll create our own extension so other other people can use so based on the community we'll be able to do all of that but in the previous class what we were doing in the vs code itself in the vs code itself we were creating python nodeb books that is I py NB interactive python NB means notebook okay it means a python uh python notebook which you can interact with interact means I'm trying to run this is my cells right in cell one I have written import OS in cell 2 I have written os. getet CWD so can I run if I run this will this code will also run no it is interactive I will be able to run cell by cell cell by cell and it links with your python envirment whatever python you have installed on your system see this is installed and this python environment is installed in your system so from your system we have installed Python and from system vs code links okay this is where vs code links vs code links to your environment installed on your system and runs this cell okay so it is vs code that has has a link to Python and is running cell by cell okay now in the vs code also we can open a terminal at the bottom okay suppose this is your vs code and uh this is your VSS code and this is your terminal okay this terminal is same as this terminal zfh command you have to go ins side folder to be able to run this command run like python. your terminal will not run cell by cell okay your terminal runs script it is the same terminal but you are watching the terminal you are you are able to access the terminal in the vs code because they have a window there okay it is the same exact terminal okay so now what we have seen we have seen now what is the difference between Python notebook I'm going to kind of merge this workflow but understand different components okay python notebook it means run cell one by one python script means we have hand lines of code okay and when we run that command with the help of terminal that is python that is script.py it will run all of those 100 lines in a single go and will give you the output or the error but in Notebook what you can do run this if it doesn't give me error run the Le line just like interpreter run one by one but here it is like a compiler it compiles all of your line of code and then run I'm talking about in just intuition okay so where you will use notebook and where you will use script so notebook is used for experimentation okay experimentation learning is also a part of experimentation only experimentation learning uh sharing files with your team because everything is in POC phase not in even POC experimentation you want to learn one by one and it's not like you have written thousand lines of code and you're debugging something okay you don't uh usually do that when you're learning in learning if something is not learning that time you will fix then and there this is what experimentation and learning means can we deploy notebooks do we deploy notebooks in product no so this is not deployment friendly okay we should not pick for deployment in case of notbook okay because who is going to be there to run sales one by one does it make sense to apply notebook in deployment that first someone we have deployed into the client and someone is there sitting there in the client deployment and doing import OS import then os doget involment does it make sense no right it does not make sense so what do we do we do experimentation in Notebook but once we our experimentation is done suppose we have done experimentation of multiple machine learnings multiple computer vision and we got to know that out of those 10 experiment I can uh create one in production because I know out of 10 one performs the best so what I will do I will take that one take with the help of notebook write the final line of code only code which is required only code which is required to run my application suppose notebook has th000 lines of code for 10 experiment for one experiment I only require 50 because I don't require all of those print statements okay all of those print statements and other things what I will do I will create a new single file from my notebook by learning it what is required what are the arguments of python and other things I will create a final script.py suppose this is my final pi and I will use my script in the deployment so at the end that's why I'm saying that Learn Python use notebook for experimentation but later do everything in script okay all of the GitHub if you see Yol and others do they have repo in their notebook do they have rep in their notebook please mention have you seen a GitHub repo a famous GitHub repo where everything is in Notebook no okay people who have not seen lot of gith repos I will say they have they will have experimentation where they are doing experimentation and you're trying to learn something in Notebook but you will never see on a script okay so keep that in mind that you are going to run in py how can you run this kind of file can you run with vs code you can run with vs code but you are going to use terminal everywhere okay but we will use terminal everywhere because that's how in production work in production you will only have suppose this is cloud okay this is cloud and you are in you're working in company X you're working in company X you have joined us CV engineer okay you have joined as CV engineer what you will what you will say that I need computer I need a powerful computer will they be able to provide you a laptop with a 100 GPU or a bigger GPU this is a kind of GPU you can search on internet this is not a desktop GPU okay this is a this is a server kind of GPU you can use in desktop but these are on servers because they are very high maintenance okay so what they will do they will ask from the cloud provider they will ask for a VM okay VM is virtual machine in the virtual machine the main operating system that is installed in almost all the VM is Linux okay so it's not like you have to uh understand Linux lot of the time you just only need to run uh how can I say how to use directory how to use remove idit and other commands other things you don't need you are not a l administrator you are just a computer vision engineer who is just trying to learn how to operate this VM uh just how to operate this VM okay so what if you connect to this VM what the only thing you will be able to see is terminal that's it you will not be able to see notebook you can connect your vs code with this VM to be able to see file structures like we see in our computer you'll be able to create notebook there as well with the help of VSS code okay you can run there with the help of vs code but the main thing in production you will see is terminal and terminal means here concrete files do not interactive the files that which I can run with a command okay yes in Linux you only need to run basic commands like copy paste change director that's it you can can use chat JP and can be a Linux administrator okay not an issue so never think about I have to again learn a new kind of language now no that's not an issue okay so this is how our workflow looks like that tools we use the python we are using the cond we are using the miniconda we are using and other things okay everyone understand the different components we are working with so if someone says open vs code terminal if you have any issue in terminal see right now we are here to help you but what happens if you move to company sometimes what I find is that in the vs code terminal some my code is not working but when I'm opening a new terminal a separate terminal not in vs code that code is working so there can be issue with the VSS code itself what can you do so think of that is the same component a terminal is a terminal anywhere okay yes reinstalling might help but when you are in a deployment and other things sometimes you require that software more than like people are saying reinstall okay reinstall is fine if you have time suppose you're in a constant environment where you're running where you're working on like three projects okay and you're continuously editing software okay if you say that I want to reinstall and debug my application in that day and suppose you have to submit the work in that day you will not be able to do it faster okay so don't get stuck by installation do it after hours your work or something but uh like there is a work around always try to find work around okay is everyone clear with this whole workflow or the tools that we use please mention yes everyone this is very important because lot of the times we don't know what we are doing these are just softwares okay what you want to achieve with that a notebook experimentation or running a script is up to us okay okay people are saying yes okay so shall we start our open CV now okay this kind of uh insights I will be giving you in like about Cloud about VM and about other things but not in just a single class Okay so this is my folder okay and let me share class two materials in chat you can use others it's not just vs code VSS code is ID of my choice you can use py Cham as well but py Cham for me is little heavy everyone please see the chat and this is day one and day two don't anyone please uh like everyone don't comment just download and see the screen okay I've mentioned for five CH don't comment okay otherwise anyways people will not be able to I think this is for everyone right I think everyone can see it okay so before that let me start one visualization that is present here okay so today's date is 23 11 24 okay okay so see this is how I can open things in vs code if you have installed vs code you can right click show more and then open with code if that is not present right click on your windows here click on Terminal and you can also do code Dot and it will open this folder also okay see yes I trust the author and you will be able to open it if you still don't want this method okay code dot then just open vs code it will open a new terminal and in that new terminal click on file then open folder then go to this folder my folder is in this place let me go inside folder okay don't want to see this and then paste that path here and press enter so you are now inside that folder select folder and you are inside that folder okay so I've shown you three methods to open yes I will share useful V code extensions later so this is how we have opened our vs code okay let me close unnecessary things terminal code see I've shown you three methods one I mostly use in Mac that file then open folder okay go to that folder and open that particular folder which you are trying to access okay see you have to be engineer everyone if one method doesn't Works try to get into the new as fast as possible okay so yeah let me minimize this this lot of information okay so first let me start with I've already given you this code so this is the first script which I'm trying to run the name of this script is RGB HSV just for visualization before starting okay then BGR then there is one gray scale as well dot Pi so this is the python file it means it's a script okay so let me run this script if I press control plus till day I will be able to open Terminal okay then here I have to activate cond EnV list will give you all the involvements present in your system as I told you this is my new pc so I only have this envirment which I set up before okay so I will do what I will do cond activate K cv1 and then okay this is poers shell see in poers Shell I might not get all the things so I I usually what I like is command prompt okay P activate KNN cv1 you can see now I am inside kcv and this is also what you can see on Linux and other terminals so now what is the file I want to run I want to run python RGB HSV and other things okay just wait everyone to see one thing just give me a second okay okay that is the main thing I want to do is that if the class is recording yeah okay so if I try to run this python RGB HSV BS so we will get an intuition that what that channel looks like okay and you can see it is probably very fast than my previous class because my system was slow okay couldn't read the frame oh couldn't read the frame because Zoom is using that so let me turn off my video and hopefully now it will run okay okay okay got it okay everyone are you able to see different cool right yes I will increase a text size okay so you can see okay all of my fingers pointing to the same because it is the same image but on the top left you can see this is a BGR image okay and people who were saying in the class that BGR and RGB I think they got their doubt cleared because right now we are writing into numai array we are not directly using CV IM show if you see the code we are writing into a nump AR so it is already being saved okay no see use the same environment everyone if it doesn't run if I change some python library then use it else use your environment okay just create a new or create use your older environment or have an environment for this class itself okay there should be separation so you can see on the on the top left there is like blue color all of my face has been replaced with blue and just below that image that is a RGB okay whatever was kind of uh brown color is now been replaced on the BGR has been replaced by a little bit of blue a dull blue okay it is not bright you can see my shirt is kind of maroon but on the BGR it is kind of purple okay because the channels has been shifted error kcv use your previous don't use kcv 1 use your previous environment everyone see I I thought people has practiced okay so please try to run that and on top right you can see HSV then if you don't remember previous type a command cond EnV list Co n da space EnV space list people who are saying no module name CB2 found please activate your old inner environment okay yes I will share today's resource again okay so so let's focus on class okay don't always focus on implementation otherwise you will skip what I'm teaching everyone please try to focus on the screen it is good for everyone okay so I'm not watching chats now if you ask something you will miss the class okay so let's focus here so on the top right you can see HSV now what is HSV how it is different from BG and RGV I will talk about in very depth and you can see gray skin just a gray skin okay just a single channel that is lightness okay only the light intensity is there in the gray skin either it is dark or light or something of a gray color okay then use cvore or base try which works for you so if I press my q key or any I usually use Q because it helps me to remember Q for Q so it works like that okay so you can see my screen closed if it is not fix your environment or do something because that should not how it works okay I will talk about everything okay so let's not talk about video capture right now because we learning few more Concepts but not this right now okay so let's talk about R GB versus h SV this is first agenda which I have not mentioned here yeah I mentioned okay more color space we are talking about but we are going in depth on HSC because it is very important for color thresholding okay so in RGB let me draw some AIS I want to draw into shape and line Y axis x-axis and Z axis okay now suppose this is the axis of let me have that same exact thing so that you can all can follow the notes okay suppose this is the axis of blue okay this is the axis of blue X is the axis of blue so as we increase from this point to this point our blue saturation will increase okay suppose blue is from 0 to 255 so we are increasing that uh values okay then this one is okay let's consider this as red and then let's consider this as three okay and this is where zero is okay so as we are increasing here our uh blue kind of getting more saturated think of this like that okay when we moving from this to this uh but in open CV it happens like zero is the darkest one so let's go from 250 suppose the center is 255 it means everything is white here okay everything is right here and this is where we are getting to a darker shade darker shade means we're tending to zero till this part everyone is clear Center is 255 we when we are moving to we are moving towards zero think of this like that everyone okay so this is the for any color the brightest color is white for any color but when we go to that it will be kind of very dark it will kind of Blackish okay so blue tends to be blackish so let's plot a cubid here okay so it means suppose this is the end so this will create a square okay and for that how should I plot it I hope I'm not making a mistake okay this looks like everyone is able to visualize this uh kind of room right everyone this is your floor this is this wall this is this wall okay so as you can see uh suppose I am picking one color here this is again separated into lot of channels lot of lines sure what I did here but okay now suppose I want to know a color of this box okay if I want to know the color of this box it means it has some amount of red also it has some amount of green right it is also in the green and you can say that blue is not here because I'm in the first part okay blue is not here so you can see blue can be or or this is will be the brightest of blue okay it means a kind of white some amount of green and some amount of red okay but again if I make a new line here okay just watch this suppose this is a new plane this is parallel to this line okay now I want to find this point okay I want to find this point so what it will be it will again be because this is red again red will be same because it is parallel to suppose this point this point and this point is parallel we will have some red again we will have the same green because the height is same but I don't want the shape but there will be some difference in blue because we have shifted to a different blue okay so it's like when we change even a single Pixel okay when we change even a single Direction in RGB space our whole r g and B has some value okay I cannot Target a specific kind of blue okay so I can only target this part H or this part or some this part but I cannot Target a particular kind of blue in RGB because it has for every color it has dependency to R and G R and G also changes this is also a blue if I if I talk about this this one has also blue but a different kind of blue okay this is also a blue a different kind of blue because RGB is additive Model A different kind of red and blue will be red and green will be added in this pixel everyone are you able to understand this rgp is a additive model so if I change even a single Pixel a different RNG will be added to the color and it will get a numeric value so I will I can only separate a very limited if I want to suppose in that in a particular image okay in a particular image if I want to Target a particular kind of blue if I suppose I want to Target Sky I have all the beach images if I want to Target sky that sky is made up of hundreds of different kind of blue but I will be able to Target suppose three or four or five but not all because it is a RGB a different red will be added a different green will be added so I will not be able to Target it correctly sir can you please explain first plane where blue is 255 because this is the x-axis right this is the center from the center we are creating this is a different axis all the values of that blue starts from zero here this is a plane of zero this is 255 suppose this is 150 and this is zero if I create a plane here okay if I create a plane here it will be zero this will be 150 blue will be 255 am I am I mentioning it right everyone am I mentioning it right yes I'm sharing my video okay so let me start my video okay so I hope everyone is able to understand this kind of cube okay so let me this is our notes page just wait okay so this is the image present in your nodes as well you will be able to understand it now okay everyone has access to this notes so they are now able to understand this particular cuboid okay you can see blue is increasing here because that is how their access is it means you will be getting a very dark blue here but if you move to that you will get a different kind of color okay so RGB is a additive model model of array yes no it's not that that kind of additive it's a different different thing you you don't add 255 plus 100 plus Z but a color that is made from different channels is additive this has different kind of RGB this has different RGB this is different RGB this is different RGB so R and G and B combined creates a new color we just don't add it okay this is now not how the channels looks like okay left blue wall should be zero uh see it should not be zero because as I told you at the start suppose we are starting from 255 and going to zero going towards 0 0 0 just a different kind of explanation you can start I'm this is my Axis okay this is you can say we can we are going in a different direction just for your explanation okay this is just for your explanation of understanding of this cuboid this is the brightest of brightest and the darkest of red this is the brightest and darkest of green this is brightest and darkest of blue all the colors this pink is made up of some of blue some of green and some of red again for this white everything is 255 255 255 yes 255 is the brightest color of any channel so is everyone clear on this concept of RGB color space is everyone clear please mention yes okay so our RGB is done so now let's talk about HSV okay now let's talk about h SV in RGB what was the range R is 0 to 2505 G is let me turn off this part G is again 0 to 255 255 B is 0 to 255 255 how many number of colors you can get in RGB space 0 2 255 into 255 into 255 okay yes 256 but we have yeah yes sorry I was wrong but yeah people are saying 16.7 Millions thanks for doing the calculation it is 16.7 million colors that is all the possible colors possible in RGB understood everyone yes it is similar to that so let's talk about HSV it is a different color space than RGB and BGR it is totally different HSV is h means Hue of the color Okay s is saturation of the color V is value of that color it means the brightness okay the brightness so let me import another image which will help us understand HSC better okay then we will talk about conversions yes I want to import image and then let's import is that SV not here let me check okay oh HSV is not here because it is a webp file so what I will do just wait a second guys okay give me a second got it so now see that's why I'm saying that don't always get the because not all the data in your not books will be latest because we are continuously updating it okay in the class also so I've also included HSV do jpeg which I will be loading in this one to help you understand better okay so now insert image and you can see HSV see HSV is kind of a cone kind of structure but in case of RGB to scroll just wait okay okay while RGB is kind of a square HSB is kind of a cone okay think of this as kind of a Coe so Hue corresponds to the color component of the color that is a base pigment so for each color there is a 360° wheel okay this is a wheel now that I want Circle yeah this is a wheel okay you can think of this as zero and this is 60° then this is this is not 60° this is 90 180 then 270 and then this is zero okay this is a color wheel when I'm talking about Hue when you see this cone the top is Hue it means you can see there is a separation of red it means red is around 0 to I'm I'm just giving an example okay because I don't have any exact value but I can see red is like from 0er to kind of 30's degree around 30 I can see red and also around 330 to 360 is also a red in this diagram everyone that is correct right okay so this is how I can see the red so as you can see in HSV I already have a separation of color okay now think of saturation can you see this inside of cone 3D cone from the bottom is zero it means the dark and when we are getting not dark the bottom is zero is mean it is bright and when we are increasing we are increasing the saturation of that color zero means we don't have any saturation it is white when we're increasing it to some value it is becoming that color suppose I starting from red with saturation of uh zero it means the red I picked is of brightest color if I increase the saturation it will become this kind of red this is the red it will make it look more vibrant okay so Hue is the base color it means we are picking some red what kind of red it's up to the degree now in that red itself what is saturation right that particular red can be little white can be little dull because there are different kind of red right in that red how much saturation we want is you can see this is also a red this is also red to us but kind of pink but in this red there is different saturation levels everyone can you see this angle can you see this angle this is saturation this is wheel this is Hue wheel this is your saturation okay now this is your value zero means the image is not at all bright the brightness is zero if you increase the brightness as you can see suppose this is this is also blue this is also blue then turquoise can whatever color you can say okay this is Canan this particular block is called kind of Canan color right so because we increasing the brightness it is also a blue that is also giving a different value so suppose in HSV now I want to separate red color from my image I want to threshold I can't see your cursor moving it is moving everyone can you see my cursor please please mention no not moving but you can see things written right okay just wait let me stop share and then start again okay there can be an issue okay only written then it's not a big issue okay can you see a cursor now okay so there was just sharing issue okay okay so now tell me in which color space it is easy I'm not talking about uh in RGB also you can separate color but in which color space it is more easy to separate or suppose I have an image of the beach and I want to separate only the blue color in which color space it is easy to separate HSV okay h H SV understand everyone is everyone clear on HSV I will I will I will talk about okay so HSV is little different I'm talking about General HSV then I will talk about open CV HSV okay a general HSV in general HSV H is H SV H is in degree saturation is in percentage value is also in percent degree means 0 to 360 percent means let's start from one okay let's start from 0% 200% V is 0 to 100 people who are asking S 0 is bright or something think about this for any color if saturation is zero it means there is no saturation saturation means that suppose I have this block okay think of saturation as a Rangoli okay the base board is white the more color you add the more saturated it will become if you add very less color on white and if you see from very top you will see little bit of pink color if you add little bit of more white more red color on that white canvas it will give you little bit of dark pink pink or a less red if you add all if you fill this with all the red you will see a very bright red so that is called saturation understand what is saturation don't think about moving inward or outward you will not always think about this cone okay yeah depth of pigment or how much pigment it is present saturation okay so that is saturation yeah kind of Purity yes you can say Purity yeah okay if this is the original red this is the original blue this is the original Green a little bit of less red will give me I don't have a color wheel here yeah let's see okay so see this is the m main raate if I increase it what value is zero zero means black I'm increasing the saturation and if I don't increase the saturation is kind of dark now and if I increase this is this is value this is brightness okay I already picked the red but what is the brightness of it this is 100 bright it means I'm getting this kind of if I Inc if I decrease the brightness of this red I will get a little dull kind of box okay and in this wheel itself this is the red this is saturation can you see this is kind of white now okay this whole line is kind of white if I increase little bit of red can you see the color change red red okay now there is some red there is more red more red more red more red more red more red very red so this is all the red we can get but also depends on brightness also depends on brightness everyone is this clear okay you can experiment you can experiment it later okay so this is what an HSV is okay color wheel and all those things so now let's talk about for RGB not with red let's go into the next page it is better now suppose I have a color I've already included all of those calculations because I was sitting all night and giving you those examples okay now Suppose there is a color let's pick a color RGB color color is what is the color we will pick okay color is 100 okay color is comma 255 comma 180 okay it means red is 100 G is 255 B is 180 okay now if I have to convert this to h s v will it means does it means that my H is 100 saturation is 255 and B value is 180 is it is the conversion should happen like this please think and then let me know is the conversion should happen like this why because my red was hand green was this is an additive model this will give me some different kind of color so let's see this color okay everyone has Google Chrome right in Google Chrome we can search wait RGB color picker okay RGB color code let's search RGB color code okay I got one website which I will show it here okay so what is the r we have picked we have picked 100 our G was 255 and B was 180 so it is some kind of uh this color RGB and see this one is already giv giving you HSV my Hue is 152 61 and so let's see in our color wheel as well okay zero what is this 152 let's go to here around this color is 152 everyone can agree right around this color is that 152 right everyone okay 152 and then there is again in the web same website you can see saturation is 61 and then it is value is 100 it means this is the brightest color we have picked okay then how we it is calculating this value we will talk about that algorithm now okay everyone we will talk about this algorithm now so let me close this and then we have covered this part okay so this is not how it works so let me erase that and at letter we will fill this part okay we will fill this part so this is about too from the algorithm we have to fill this part okay uh please explain this part what part said explain this conversion or something else please mention fast okay okay I will explain this conversion it is very simple and also in that one I've written the code and the algorithm so let me write it okay so algorithm step one this is RGB okay algorithm step one so first let's get divide each uh the color range okay divide each RGB by 255 first let me write the algorithm okay let's me write the algorithm second is from the division we need to find out compute cmax that is color Max comma color minimum than difference of cmax and C Min this is the second part in third part we have to calculate U this is how we calculate H okay so let's calculate U so how we calculate U if my C Max okay and C Min is equal okay if both C cement are equal then U will be zero okay this is the first example no it's it's not like that see we are building things from like we are learning fundamental things so there is nothing like we should always apply that okay this is the first condition second is if cmax is equal to R okay I will talk about what is r if cmax is R then what we will do we will do this computation of let me scroll a bit we will do this computation of of U = to 60 into that is Multiplied G minus B let me write as G minus B by the difference this is the formula later we will talk about what is this formula okay then plus 360 then modulus 360 this is when the cmax is r i will talk about what is cmax is R then if cmax is equal to Green Let's me write it first then hu will be 60 multiplied by then the color will change here B minus r then the difference then + 120 modulus 360 okay this is dff okay then the final is if cmax is equal to we have covered G we have covered R then it will be B okay then my H will be same thing 60 multiplied by R minus G because this is for B so we will do for R minus G then divide by difference okay then plus 240 then modulus 360 this is the formula I will talk about every components now this is not a huge formula see uh once we calculate it you will see it is very simple okay this is to calculate Hue now the fourth step we have calculated Hue from this first step we will calculate then I will give you an example and then we will solve it very simply okay it will not take long then we need to compute saturation for s if C Max is equal to zero then saturation will be zero whatever the cmax is the value is zero saturation is zero if cmax is not equal to zero if cmax not equal to zero then the formula is difference by cmax into Andro okay guys just watch this and later we will talk about the formula okay and then see for cmax if the cmax is zero saturation is zero lse whatever the difference is divided by that particular cmax into 100 will give you saturation okay then value is simple value is cmax into 100 so you can see a lot of dependencies from cmax and cmen okay so now let's go to our number let's pick the value again as our main value was 100 this is r g is 255 B is what was the B 180 okay we have because we have answer for this in the internet as well in the different value so everyone please see here don't watch any code don't watch anything please watch here okay so first the first step is 100 by 255 is equals to around 0.392 I've computed this before you can do the same for green 255 by 255 is equal to 1 then for B 180 by 255 will give you 0.706 okay so now cmax here is that what is the largest color C is color color maximum is we got the value color maximum is cmax is equals to Green is equals to 1 C Min is equals to Red is equals to 0.392 have you calculated cix cmax and C Min now everyone okay second now see the algorithm for second Point compute cmax C we already computed the different of cmax and C Min so let's calculate the difference so d i FF equals to cmax minus C Min which will give you 0.608 so this is D let's go to step three in a step three we have algorithm for to calculate U so is cmax and C Min are equal in our case no one is one and other is 0.392 okay both are not equal is our cmax is red please mention yes and no now is our cmax red no is our cmax green our cmax is green can you see because one when we calculated our green divided by 255 the highest color the the highest number on that is the cmax and the value for that is g okay so our this one is green so what we will do we will apply this formula okay we will apply this formula so let's apply this formula because it is G if G then we will apply that G's formula G formula is 60 you can do this star because we because it is for green so here it will have B minus r this is the formula don't ask me why B minus r we can probably calculate it later plus 120 whatever the results is modulus 360 okay so 60 into B minus r will give you around okay let me write it 0.706 is the value of B 0.392 is the value of R you can see our B is 392 0.706 right what is the difference we got the difference is 0.608 608 then we will close this okay so this one is closed this one is closed this is the main bracket and then this is plus 120 then we will close this okay then modulus 360 so first we will solve this part okay first we will solve this part because it is inside the most inner bracket okay so 60 into this part is 0.516 once this is solved the we have to multiply this with 60 because of B Mass because this one is bigger okay then this one is not like that okay oh what did I do yeah first we need to calculate this part right we have to first divide this value by six we will divide this by 0.608 then we will close this then plus 120 and whole output of this will then be multiplied modulus by 360 okay then the output of this part that is 0.516 by 0.608 is did I do something wrong here yeah okay sorry I think there is something wrong here this value should be 0.314 I think people have mentioned the same in the chat yes yes thank you for helping me okay people are saying 308 is it 308 I thought it is 314 yeah 314 yeah okay this this is correct so 314 divided by 608 will give you 0.516 okay so this is the value of this plus 120 and then modulus 360 okay five participants have raised hand how do we get mean and Max how do we get mean and Max for RGB we have divided whatever the RGB was with 255 because of highest intensity okay then we will get uh it is like uh normalizing it okay then we will get this value for R for G for B the maximum value of this three will become cmax the minimum value out of this three will become C Min okay then what we will do we will do this calculation this will bring us to 160 to 0.5 around 30 right so 30986 + 120 by 360 then this will give us 1.98 modulus 360 because this number is already smaller than 360 the modulus will be this so this is what we have calculated for H everyone this is what we have calculated for H saturation and others are very simple if saturation is now the step of four was saturation what is the value of saturation when we compare C with r or g whatever the minimum was we will compare that okay we will pick that RGB we will pick that okay cmax into 100 what is the cmax see again this is the algorithm if cmax is equal to zero then saturation is zero but if cmax is not equal to zero difference divided by cmax into 100 okay difference divided by cmax into 100 what is the difference difference I think we have calculated our difference was 0.6 68 by 1 is our this part and this is 100 so what we will get we will get 60.8 as our saturation this is saturation final Point final point is very simple fifth what is fifth TMax into 100 I think that is the the formula let's see the formula yes formula for value is cmax into 100 this will give you cmax was 1 into 100 will give you 100 okay so let's see this this is value so we got value as 100 saturation as 60.8 and H as 1 15.98% RGB color code sorry I'm kind of deleted it our R was and 255 then 180 is this the same value we are getting or not there can be few Precision points like we got uh H has 15098 we got 151 here it is 152 so there is some few Precision values here but it is 151 in another website might be you can be finding 151 as well saturation is our saturation was 60.8 it means if you round it off it will be 61 and value is hand are we able to calculate the HSV for this value or not everyone did you like it to this part or not did you learn something new see I know a lot of people are already from computer vision my might they might know but the point of this is to yes I will add this part that's why I'm saying right I have to again update the drive that's why I'm not giving you the link so this link is not the final thing okay sir thanks thank you calculation see you don't have to do calculation BGR to HSV okay CV2 coloror BGR to HSV that's what you have to do but this is how the understanding you might be thinking that this is RGB okay let me run this terminal again okay we have the terminal right this code okay uh my video again let me pause it else it will throw an error you can see me four times okay I will give you an ination just wait okay I think it is loaded it is already loaded here so you might be thinking that this uh bottom left is RGB how it is going to this top right as a as HSV what calculation is happening my red is becoming kind of pink my shirt whole shirt is kind of grayed out now it is not good for visualization it is good for thresholding okay it is good for thresholding visualizing it will give you a totally different thing our we as a humans C is kind of RGB right this kind of additive kind of function but HSV is totally different visualizing it is giving you weird things okay you should not directly visualize HSV what what good it will give you it is not a traditional method which you are used to like RGB it is HSV something different okay I will update today's resource because I am adding few things I will be adding this resource also our note of today's class in that Google Drive so after class I will update that okay I will talk about thresholding I will talk about HSV that where to use HSV now okay don't worry so for people okay let me uh press Q okay so here we have completed our this part so again see people who are confused and not getting the intuition of saturation okay see this is the blue IM okay this is my current uh blue what is the color here what's the color here kind of very white okay all the bottom color is white so it means the color is not at all saturated color is not at all saturated okay let me talk about saturation and giving intuition when you buy a new cloth right when you buy a new cloth if you wash it for the first time or second time you will see the color mutes mutes down okay mutes down to some degree what you bought at the start is not a color so what you are doing you are increasing the saturation is in decreasing what is the base color of any cloth the base color is white they color it they add the color right so when you mute it down to the original color you will be reaching to some kind of white or a dull kind of white that is a saturation decreasing understand so for this blue this particular blue it is a darkest of that particular saturation if I go little like I'm muting down okay so for this yellow C okay for this yellow and for highest saturation highest value first focus on saturation this is the brightest saturation of this yellow I'm muting it down I'm washing my cloth washing my cloth washing my cloth washing my cloth washing my cloth now it is all becoming white okay it is all becoming White is my voice a bit low said others no my voice is not low okay so this is about saturation I'm muting the color down the word is muting or whenever you want to get intuition just wash anything okay if you go to some like for uh doing some painting in your home and they want you can at least say that this is the mo color I want to mute it down what they will do to mute any color down they will add less color of it they will add less color of it so that is saturation now for this particular color we have done our saturation part is done I have picked this much yellow I want to put now on this much yellow how much brightness I want okay brightness you don't add brightness in cloth directly but brightness is like how much of suppose how much of white you are saying okay suppose the this is the yellow you picked with a with no white okay so what will happen the brightness is all zero the brightness the value of the brightness is all zero it means it is all black let's add little bit of brightness brightness brightness you can see there is some brightness to this yellow and it is becoming very dull black kind of yellow okay now let's add little bit of more yellow it has become again but better than before it is still a yellow but very dull kind of of yellow increase increase you increasing the brightness so that is what this is understand play with it to understand it see uh it's not like I understood saturation brightness from computer vision everyone is photo editing app they they move their sliders of saturation and brightness right everyone edits their photo let me turn my video on because it is off is interactive HSP is a combination of RGB no HSV is different right it's not a combi
Original Description
Check out our Live Computer Vision GenAI Bootcamp
https://learn.krishnaikacademy.com/l/983696c5fd
Reach out to Krish Naik's counselling team on 📞 +91-9179733440 in case of any queries we are there to help you out.
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Krish Naik · Krish Naik · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Natural Language Processing|Stemming
Krish Naik
Natural Language Processing|BagofWords
Krish Naik
Gaussian distribution or Normal Distribution in statisctics
Krish Naik
Natural Language Processing|TF-IDF for Machine Learning| Text Prerocessing
Krish Naik
Log Normal Distribution in Statistics
Krish Naik
Covariance in Statistics
Krish Naik
Confusion matrix, Precision, Recall| Data Science Interview questions
Krish Naik
Tutorial 44-Balanced vs Imbalanced Dataset and how to handle Imbalanced Dataset
Krish Naik
Implementing a Spam classifier in python| Natural Language Processing
Krish Naik
Tutorial 11-Exploratory Data Analysis(EDA) of Titanic dataset
Krish Naik
Face Recognition using open CV and VGG 16 Transfer Learning
Krish Naik
Pedestrian Detection using OpenCV from Videos
Krish Naik
Face and Eye Detection from Videos using HAAR Cascade Classifier
Krish Naik
Reading, Writing and Displaying images with Opencv| OpenCV Tutorial
Krish Naik
OpenCV Installation | OpenCV tutorial
Krish Naik
Face and Eye Detection from Images using HAAR Cascade Classifier
Krish Naik
Car Detection using HAAR Cascade and Opencv from Videos.
Krish Naik
Using OpenFace for Face recognition in Keras
Krish Naik
OpenPose Tutorial with Tensorflow
Krish Naik
Multiple Linear Regression using python and sklearn
Krish Naik
Dimensional Reduction| Principal Component Analysis
Krish Naik
Movie Recommender System using Python
Krish Naik
TPR,FPR,FNR,TNR, Confusion Matrix
Krish Naik
Precision, Recall and F1-Score
Krish Naik
Artificial Neural Network for Customer's Exit Prediction from Bank
Krish Naik
GridSearchCV- Select the best hyperparameter for any Classification Model
Krish Naik
RandomizedSearchCV- Select the best hyperparameter for any Classification Model
Krish Naik
K Nearest Neighbor classification with Intuition and practical solution
Krish Naik
K Means Clustering Intuition
Krish Naik
Create custom Alexa Skill- Lambda function- Part2
Krish Naik
Hierarchical Clustering intuition
Krish Naik
Implement Transfer Learning with a generic Code Template
Krish Naik
Gender Classifier and Age Estimator using Resnet Convolution Neural Network
Krish Naik
Unlock Your Application With Your Face using OpenCV
Krish Naik
Draw rectangle from webcam and sketch process it on a live feed
Krish Naik
Complete Life Cycle of a Data Science Project
Krish Naik
How we can apply Machine Learning in Finance
Krish Naik
Deep Learning in Medical Science
Krish Naik
How to switch your career to Data Science.
Krish Naik
Linear Regression Mathematical Intuition
Krish Naik
Handle Categorical features using Python
Krish Naik
Machine Learning Algorithm- Which one to choose for your Problem?
Krish Naik
DBSCAN Clustering Easily Explained with Implementation
Krish Naik
Curse of Dimensionality Easily explained| Machine Learning
Krish Naik
Feature Selection Techniques Easily Explained | Machine Learning
Krish Naik
Tutorial 29-R square and Adjusted R square Clearly Explained| Machine Learning
Krish Naik
Cross Validation using sklearn and python | Machine Learning
Krish Naik
Handling Missing Data Easily Explained| Machine Learning
Krish Naik
Deploy Machine Learning Model using Flask
Krish Naik
Deployment of Deep Learning Model using Flask
Krish Naik
How to Visualize Multiple Linear Regression in python
Krish Naik
K Nearest Neighbour Easily Explained with Implementation
Krish Naik
Predicting Heart Disease using Machine Learning
Krish Naik
Predicting Lungs Disease using Deep Learning
Krish Naik
Stock Sentiment Analysis using News Headlines
Krish Naik
Random Forest(Bootstrap Aggregation) Easily Explained
Krish Naik
Voting Classifier(Hard Voting and Soft Voting Classifier)
Krish Naik
Credit Card Fraud Detection using Machine Learning from Kaggle
Krish Naik
Hyperparameter Optimization for Xgboost
Krish Naik
Tutorial 45-Handling imbalanced Dataset using python- Part 1
Krish Naik
More on: CV Basics
View skill →
🎓
Tutor Explanation
DeepCamp AI