Hello everyone. In the previous video we have imported all our dependencies for the course. Right now we will write our first function image loader. It will be used to load a single image from our disk. Just a quick note before we start with implementation. For each function that we are going to write and of course, I will write his head before the video.
As you can see for the one right here, it will allow you to focus on the meat of the code, which we'll discuss in the video. Image loader takes two arguments. Image path, which is a string and it is full location of an image that we want to load. The second argument is image size. This will be patentable with width and height of the output image. To read an image from our disk we are going to use in read function from open CV library.
It takes a while argument and this is our image path. If you have worked with open CV library before, you probably know that it loads images in BGR format instead of RGB. To bring our image back to RGB, we will use convert color function. This function takes two arguments. First, our image and open CV flag that indicates the conversion pair. In this case it is BGR to RGB.
The only thing left to do here is to resize the image to the given image size. To complete this operation, we will use the resize function that takes three arguments, our image new image size as a titan topple, and lastly, we have to provide an open CV flag for interpolation type. Here we will choose cubic interpolation. If you're not familiar with the concept of interpolation, it is essentially a way to To fill a missing data, or in this case to resize an image could be downsize or upsize. And interpolation is here to try and to retain the quality of the input image to complete our image loader function will return the image. And that's it for our function and the video.
If you have any questions so far, post them in the comment section. Otherwise, I'll see you in the next tutorial.