Welcome back.
In the previous lesson, we have seen how to read an image using open CV map plot live and below.
And we understand that each and every tuple of three values which represents a pixel.
In this case we have a color image and first one represents the red.
Second one is green and third one is blue.
And in the case of OpenCV, it is b, g, r format.
Now let's see how to display the image.
We can display the image using either open CV or also we can display the image using math plot.
First, I'll show you how to display the image using OpenCV.
Okay, so this is my display image using open CV.
We can display the image using OpenCV by CV two dot m show.
And here we need to provide the window name.
This is the name of the window.
Let's say I'll set that this is my window underscore name and and matte map is basically defines the
array me display the OpenCV image which is img underscore CV.
In order to display the image.
We also set the two parameters.
One is weight key, and second one is destroy all windows.
Let's set this weight key.See the dot weight key.
Make sure the key is capital and we need to provide the delay briefly indicates like no weight for the
pressing key.
As soon as you press a key, the window will get closed.Set this to zero.
Now, let me also set destroy all windows means as soon as you press a key, I need to close the windows.That's what I'm specifying here.Now, let's execute this.And this will display the image.Here we go.This is what an image of open CV coal.And what I can see is that this is a remember, this is a b, g r format.Open CV assumes that what other image comes to you?It's a BGR format, and that's why it displays in that face in that fashion.Now let us say how to display the map, plot, lip, image.
Okay, this let me say this is my big open CV.BGR, of course, that will be much more clear.
And the next thing is, let me also display CV two dot m show and I'm going to display the map plot
live.And this is remember, this is an R format and the matrix is image underscore Matt similarly also displayCV two dot m show and let's provide the pillow image.This is also our g b and remember we need to provide the array here.That's what we need to provide here.Is that some matrix?Okay, sothat is what image underscore pill underscore array.Now let's execute this which will display all three majors.The first one is open CV and B this is my BG image and Matt plot lib image and this is my.
Pillow image.Okay.One thing we can understand is that pillow and the RGV looks much more similar because this and all the to RGV image. But whereas open CV is a BGR image.
So what difference you can find here is between the open CV match plot is you can notice that the colors got into change wherever there is a blue and that's called interchange with the red and wherever there is a red, it's called interchange with the blue.
Since blue come first in OpenCV, whereas in mad plot lib ah comes first and the last will be the blue.
So here the two colors court interchange. But you should not be worry about the coloring here because information is always same irrespective of what color it is. We can convert that into again RGV and look into that. That's also is possible. So this is how we can display all the three images using open CV. In order to close this press escape that will close it.Okay.Now, I'll show you one more. Method is displaying a major mad plot lib. So let's play a mage using mad plot lib.You can also display the image using the map plot lib.
For that we can use plot dot aim show, which you already saw in the previous lessons.
And we need to provide the x axis basically that let us display the image underscore CV, which is my
open CV image.
Let me set plt dot axis and set to off because I don't want to display this and let's set the titlehere so, so that it is easy for us to understand this is my open CV image and remember it is okay let
me set this is b g r image.Now let's execute this and here we go.This is what happening here.
This is the difference.The map plot assumes that the image, whatever you're passing to this is an R, g b format means red come first and for the green and then blue.
But since our image is in the big R format.So that's the reason.
This is the color, it's what's happening.
And that's what this is what's happening here.
Okay. Similarly, let me also show the different images. That is the map plot lib and the pillar.
All right.So for that, what I will do, let me use a subplot, plot dot subplot.
I'm going to use three comma, three rows or I can use one row, three columns and this is one.
Okay. Now let's copy this and paste it here and paste it here. So this will be to.
Now the image I want to display is img underscore Matt. This is my Matt plot clip, which is my r gb image.
And similarly, this is my pillow area, which is also an odd GB image.Okay.
Finally, political show.
This is three.
Now execute this.
And here we go.
This is my open CV.
This is my map plot lib.