Reading, Writing and Displaying images with Opencv| OpenCV Tutorial
Key Takeaways
Reads, writes, and displays images using OpenCV
Full Transcript
hello guys welcome to the first coda log series with open CV so in this particular session we will be basically seeing how to read write and display images with open CV so first of all as usual if you are imported the open CV we just have to install this particular open CV so I have installed it perfectly it is not giving me any error so that basically means that my installation has been done perfectly right now the next thing that I am going to do is that I'm going to use numpy the reason why I am going to use number I'll just tell you in in a while so here in open CV in order to read an image we have basically a function which is called as CV to dot I am read I am read function okay I am read function it will help you to load an image from a particular file if you just see the definition just go over here press shift am if you want to execute any line of Quran and basically I am showing you this in Jupiter notebook the reason why I'm showing you in Jupiter notebook is that because we'll be able to see the diagram very clearly whenever our diagrams gets displayed in front of our notebook right so this CV to dot I am bring and I'll just press shift tab and it helps me to load an image from a particular file I have I have I have a file which is called as elephant jpg which is basically a image of an elephant so what I'll do is that I am first of all store this variable inside my variable that is stole this particular image inside my variable which is called as importance okay now fine now by using open CV I have read that particular image okay the image is stored in currently in a particular variable and then what I will do is that I'll in order to show that in front of a user in order to show that particular image in front of a user what I will be doing is that I will be using another inbuilt function which is called as see me - dot I am show okay and if you just go and press shift up over here it will say you that displays an image in the specified window right so first of all the first parameter in this I am show is basically what title you want for your windows name okay what title you want for the windows where the image is getting displayed what title do you want in this so I'll just let me write it down as you know test elephant image how test elephant image whereas the second parameter that you see is basically my MIT okay if I just go and play press plus if you go and see a way of what is MIT it is basically the image I think it is not written over here but yes this enmity is basically nothing but the image variable image variable that I have actually read okay by using C v2 dot I am red okay so first of all you are reading the particular image by using I am red and then you are using I am sure to display the particular image okay so this after we execute this line what happens is that I am a Windows popper you know a window pop up and that in that particular window the window name will be testing different image and the windows action be displaying the image itself then after that we will be using one more function inside c v2 which is called as wait a wait key what does it do with that as soon as that particular window is open right unless and until I do not press any key it will not get closed so that is what this particular wait actually specifies right so way I am going to use C B to do dot wait key now as soon as I click any enter any button right that particular window will be closed and simultaneously I will also destroy all the other windows which I have displayed in the form of images okay suppose before this again I have used many times I am sure I am sure I am sure so this I am so functions actually help you to create another another windows whether I image will be display so after this wait key I'll be destroying all the windows because I need not I do not have any windows after that so now let me show you how as soon as I execute this how it will be looking like oh as soon as I execute this so here is my window that has got display so you can see that my title name is over else test elephant image and this is my a image of the elephant right now you see this I will press one enter key or any keys or from a keyboard as soon as I enter that window it gets closed and this is good as for executive this is the basic way of reading the image by using I am read and I am sure and I am showing basically you should displaying that particular image okay so over here I've given you know lot of lot of comments over here so just go and you know see all these comments and based on these comments please go and understand it if you want to just read it do it without comment so I have removed all the all the comments that was present on top of the that particular I mean in this particular tab all the comments I have removed and this is how my code looks precised I'm going to import cb2 then I'm going to read this particular image and this image is basically my elephant elephant dot jpg right then I'm going to show I am show hello world hello world is basically my text title but I'll just convert this into s defend nature then I'm going to put wait key wait Kia zero is like specifically no if I if I just say zero over here you know where the comment is that by placing number zero expects you know we can a specified delay for how long you keep the window open let me just execute this awesome I have got a ll the reason for the error is cuz I have not given my jpg in the correct format it was PNG over there so here it is now you can see that after pressing enter it will wait for 0 seconds and it will flows the window that is what this particular thing specifies you know it key value but it is always there you don't specify anything and this is my image to press ENTER and displayed encroached now you should understand at how this images are actually composed of you know now when I see this particular image right it has some height it is having some height right it is having some width and this all images you know colorful images are basically in the form of RGB channel that is red green blue yes if you if you have seen in your high school studies if you have done that or if you have come into an engineering I think in engineering you had some subjects like computer graphics file and there you have seen that any colorful images will basically be in the form of RGB Channel different channels will be there it will be having some height and width so if you want to see what is the height and width of this particular image along with how many channels are there for this colorful image what we have to do is that first of all I am going to input numbers then this is the input right this this this basically is my image which is the window that I displayed my image into so this input dot shape if I do this shape will be giving me three values the first value is basically my height the second value is basically my width and the third value basically specifies that how many channels I have so currently it is a colorful image so it is having three channels as if I have a black and white image then basically it will just have two channels you know oh sorry it will just have one channel because black and white right in that particular way it is if you want to see a particular example with respect to black and white I can just show you in a while okay so before that let me just show give the dimensions of the array now I am going to print this height of the image hide image and I am just taking the int input dot shape 0 if I do input dot shape 0 you know then that is basically going to give me the value of this particular first value that is 5:19 the input of shape of zero is nothing but Phi 19 which is my height right similarly with respect to width I have this and just change this code a little bit because that print was for 2.7 version now currently I'm changing into 3.6 so this is my width of hit of width of image and I'm just taking as shape as 1 and let me just see the output out case I can see that the height of the image is Phi 19 pixels which is Li right width of seven seven eight this is basically my width of image so I'm getting this value a 7 7 8 o if you want you can save this image in the form of another thing like in all the way also right now another way also you can actually save this particular image cuz you have read that in measure and you want to save it into different format like jpg PNG or other kind of formats you can just execute and and there is an inbuilt function which is called as I am right ok I am right if you just press shift up you'll be able to see that saves an image to a specified file and by default this image will actually get saved in the current location that is present in this computer vision right so this is my output and this is the format like jpg and PNG now you can see that as soon as I execute this come true if I go and co-heir to file has been created which is called as output dot jpg and output dot PNG Oh the video we have seen three things how to read the image by using I am read okay to display it by using I am show and the third thing we discussed about what is the height width and channels or colorful images we basically have three channels no and for black and white we just have one channel okay and then I showed you how to take up the height and the width of the images right and then finally how to write the images in different different formats by using I am write function I hope you like this video guys oh please do subscribe the channel make sure you share with all your friends who require this kind of L and happy learning I'll come up with the next video which is something called as grayscale in it I'll see you in a while ah thank you one and all happy learn English
Original Description
Here is a detailed explanation about how to read, write and display images using Opencv
Github url: https://github.com/krishnaik06/Computer-Vision-Tutorial
Follow me on facebook:
https://www.facebook.com/Machine-Learning-And-AI-1044537319033065
Below are the other playlist
Machine learning: https://goo.gl/XhHdCd
Deep Learning : https://goo.gl/iwek57
Statistics in ML :https://goo.gl/x7mkUH
Feature Engineering:https://goo.gl/6wiaGt
Data Preprocessing Techniques: https://goo.gl/YfC9Kc
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Krish Naik · Krish Naik · 14 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
▶
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
🎓
Tutor Explanation
DeepCamp AI