Image Processing with Pillow - a Python Code-Along
HTML-код
- Опубликовано: 19 июн 2024
- In this lesson, we'll focus on the Pillow Python library, also known as PIL.
I'll show you a few basic functions and useful tricks to manipulate each and every pixel on a given image.
By the end of this video, you'll know how mathematical operations affect images and you'll be comfortable with exploring Pillow further on your own!
#imageprocessing #python #pillow #PIL #computervision
Project files & code:
github.com/MariyaSha/ImagePro...
Timestamps:
00:00 - Intro
01:15 - Import PIL functions
01:35 - Load an image and display it
2:17 - Image attributes: size and mode
3:16 - Plotting 2 images inline (Matplotlib)
3:36 - Multiply / Merge Images ImageChops.multiply()
4:36 - Adding Images / Finding the common area with ImageChops.add()
5:13 - Change color mode to Greyscale and Binary
6:34 - Mapping pixels / Creating image coordinates
6:59 - Accessing individual pixel values
7:44 - Converting an RGB image into Binary with a nested "for" loop
9:06 - Converting a Greyscale image into Binary with a nested "for" loop
10:19 - Selecting image regions with row and column conditions
11:30 - Invert image with ImageChops.invert()
12:30 - Rotate image with PIL.rotate()
13:18 - Gaussian Blue and Edge Detection with ImageFilter
15:10 - Outro, thanks for watching! :)
Pillow documentation:
pillow.readthedocs.io Наука
I am grateful for this tutorial. I used some of this video's content to complete a task set by my professor: to write a program that will process a black and white image, identifying the border pixels, and colouring them red.
This is a very helpful tutorial to understand the basics of Pillow. Thank you very much.
Oh finally, simple, minimal and succinct. Thanks Lovely Mariya.
It was very useful to understand the ideas behind how pillow handles images.
Ty a lot!
I loved this tutorial!!! Thank you so much!
I'm from Brazil, congratulations, your classes help me a lot
Thank you , this video helped me with images processing. Great channel
Very nicely explained video! You clearly know your stuff!
Finally someone is talking about Pillow! I have done lots of image manipulation with MATLAB in my undergraduate course and I feel the Pillow library comes the closest to that. Nice one Mariya!
P.S. Love the Rolling Stones reference! *wink* *wink*
Thanks so much for the great content you're sharing!
All other brilliance aside, also absolutely impressed with your knowledge of Rolling Stones lyrics ;)
love it 😍 thanks for sharing
Clear and perfect pace for me, thanks .. sub
Oh look.. it's my favorite python teacher.
Thank you so much for your support Rishabh! I'm always so happy to see your comments! :D
Thank you so much 🥰❤️
Great lectures.... 👌Really enjoyed them
Thank you Romir, I'm glad you liked them!! 😁
Hi :) great video thank you. Do you know a way to use the imagestat module of python to compare the RGB histograms of two images? Thank you
very helpful tutorial
Brilliant
Enjoyed watching ur vedio mam, keep up ur good work like this. Thank you
Lot of respect from India. Really appreciate ur work
@@ashashaikh3421 Thank you so much Farzanna! I really appreciate your kind words and sending you lots of love all the way from Canada :) Namaste!
I have one doubt at 7:41. Why did we start from 1? (merged.size[1]) Shouldn't this be starting from 0? Apart from this, I super loved your video. And yeah you were very enthusiastic in teaching this topic 😊
Very good video!
What is the difference between pillow and processing-py?
Nice tutorial
Awesome vid. But does pillow or opencv able to read and process 32-bit full float exr or tiff images?
I have a 32 bit geo height map that I want to process using python script but don't know if there is a module that can read and process it.
That Lady is what every (and not only) python programmer is looking for. Amazing
Awwww.. thank you so much Maksymilian!! 😊
Great
Hey, great video. Do you have any content that explains how to display multiple images from an array INSIDE of a GUI? I know how to place images individually as labels, and I know how to use PIL to open up a folder of images on my desktop separate from the GUI. I've gotten as far as adding those images to an array, but am stuck on how to actually pack each image into the GUI. I am only able to open them with .show(), which again opens them up on my desktop as if clicking on the image normally. Thanks.
ty
nice job!
thank you! :)
❤️
Hi, new to your channel. Great work! I will definitely check out more of your videos.
Please explain to me why at 2:10 calling "O" displays the image. How come you don't have to use .show() ?
Thanks
Thank you Martin, welcome to the channel! 😀
Whenever you use a notebook interface (Jupyter Notebook, Google Colab, etc) you can bend the rules a bit 😉
Every time you call a variable in the last line of the cell, you do not need to specify "var.show()" or "print(var)", you simply call "var" and the notebook automatically takes care of displaying it.
However, if you're looking to display a few variables - you won't be able to skip .show() or print().
For example:
print(var_1)
print(var_2)
var_3
Is a perfectly normal way to print all 3 variables (as long as 'var_3' is the LAST line of code in the cell)
Hope it helps! 😃
@@PythonSimplified notebook users are cheating
How can I employ python pillow library in autolisp programming for kml file extraction?
absolutely sublime & studentfriendly DIP lecture from a really good mentor .helped me to understand easily & quickly .would you like to make a video for me on 'haar transformation' miss?!
Thank you so much for the amazing feedback Rezwan!! :) If I knew what Haar Transformation was, I would probably be happy to help! Transformations, math-wise, usually mean that you're multiplying your image matrix by another matrix that holds the specific values of the transformation you're looking to do, that's all I can tell you at this point! XD
@@PythonSimplified thank you miss ..u explain everything so easily that everything is simplified :)
Explain Pillow versus PIL. Also good job, subbed.
if i'm not mistaken PIL has not been updated in years, so basically pillow is the substitute for PIL that still has support
@@cferracini it's gets confusing because we still import pil to access pillow. that threw me for awhile but figured it out. Thanks for tutorial and reply.
Buen video :)
Gracias! 😄
Mam how to overlay a image with less opacity in python pillows please answer
Am trying to convert gif image into text using opencv and pytesseract but i can able to get the accuracy only 40%.. pls help me to achieve this
Ma'am can you make playlists on open cv, tensorflow and more stuff like that.
Absolutely! OpenCV is in the making (it's going to be a rally cool project video, rather than just a lesson) and Tensorflow will take some time to do, because I want to go over Pytorch first, but I will definitley cover it! :)
I ❤️ Python.. but I ❤️ Mariya more..😁
noice
Hello, your video is good 👍, but can you zoom in , because there's a lot of white spaces and the code is very small for the mobile users , and thank you .
Thank you Noor! I've changed the zoom values on my computer since this video, if you'll check out my new stuff you'll find much larger fonts which should be suitable for mobile 😊
I love girls who can code. I love when they programm the oven or the other kitchen supplies.
Hi Marjia, I tryied this code:
from PIL import Image
pics = 'C:\Users\directory1\directory2\directory3\directory4'
for i in pics:
pic = Image.open(i)
new_pic = pic.resize((300, 300))
new_pic.save(i)
It returned:
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
What did I do wrong?
Hi Bruhlickd! :)
You need to specify the address of each picture rather than the address of the folder.
for example:
pic1 = "path/to/directory4/img1.png"
pic2 = "path/to/directory4/img2.png"
my_pics = [pic1, pic2]
and only now you can call the for loop on "my_pics" ;)
also watch out from the resize command, as I believe you need to keep the same ratio as the original image so if it's not square - the 300x300 might give you an error too (but this one I'm not sure about, so I must warn you in advance hahahaha)
Good luck and I hope it helps!! :D
@@PythonSimplified Thanks a lot, Marjia! I'm new on Python. How could I specify the address of each picture in an easier way without write them one by one? I tried this one:
import os
pasta = '.\\direct1\\direct2\\direct3\\direct4'
for i in os.walk(pasta):
print(os.path.realpath(i))
However it doesn't show the real path of the archives. What am I doing wrong?
Hi , plzs tell how to open any image in Tkinter without specifying its name
Please make a tutorial how to create train val test dataset of images🙏
Maria your thumbnail is hilarious
Thank you! 😁
It's the first thing that came to my mind when thinking about pillow 🤣 hahaha
Could you convert an Image to its numerical base code, pls?
Você é brasileira reconheci pelo sotaque!
Heyy, can you please make a tutorial on open cv, btw your videos are really cool you explain each and every thing so that who's following your tutorial will never get stuck unlike other tutorials XD. (I skip my online class and watch your tutorial cuz they teach like shit) hahhaha
Thank you so much Abhay! I'm really glad you like my videos! 😁😁
I was planning to do one on Open CV and real-time phone camera streaming... it might take me some time as I'm in the process of moving from one apartment to another, but it sure is on the list! 😉
@@PythonSimplified Wow you replied me nice....when you started learning python?...is it ok if we learn it at the age of 16(my age)?..........and which is the best IDE for python
@@abhaysharma1139 age doesn't matter when it comes to learning..
Can I Display video with pil
Not entirely sure... I'm not aware of a way to do it - but you can definitely display it with OpenCv! 😊
I'm showing how to do it in the end of this video:
ruclips.net/video/UdCSiZR8xYY/видео.html
Just replace the streaming link with the URL of your video and it should do the trick,
Good luck! 😀
me: woah i didn't know a girl programmer existed
mariya: yes
AI and PS still on taskbar :-)
11:43 well it's _monochromic_ to be exact.
ModuleNotFoundError: No module named 'PIL' ..... i have python 3.9
hmmm... it's a bit tricky with Python 3.9 because it's soooo new and Pillow is not very frequently maintained. I'm not sure if it's integrated yet, so my best advice is to go back to Python 3.8 until they figure out all the bugs and integration problems with the older libraries. If you're using Anaconda, just create a brand new environment and install the old version of Python inside. This will not delete the current version, and you can go back to using it as soon as they finish solving all the problems :D
i will down grade to python 3.8 thank you very much for advice 👍🏼 @@PythonSimplified
Oo nice girl)
6:34 oh finally you switched to a different cell. You look like a .py user more than a .ipynb one 😜
Thank you for the erection; I mean explanation. Really helped my confinement time pass faster.
Video processing 😟
Can I get a job with turtle drawing along
are you also russian? :)
I sure am! 😃
(originally from Crimea, but I've immigrated twice since, therefore the exotic accent 🤣)
Arabic Subtitle, Thank You