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
  • НаукаНаука

Комментарии • 87

  • @uddiptagogoi1792
    @uddiptagogoi1792 Год назад

    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.

  • @AK-hg5ti
    @AK-hg5ti 2 года назад +3

    This is a very helpful tutorial to understand the basics of Pillow. Thank you very much.

  • @eugenetapang
    @eugenetapang 2 года назад

    Oh finally, simple, minimal and succinct. Thanks Lovely Mariya.

  • @danielepolverigiani2493
    @danielepolverigiani2493 3 года назад

    It was very useful to understand the ideas behind how pillow handles images.
    Ty a lot!

  • @fernandacoelho7035
    @fernandacoelho7035 3 года назад

    I loved this tutorial!!! Thank you so much!

  • @tomsantos220
    @tomsantos220 8 месяцев назад

    I'm from Brazil, congratulations, your classes help me a lot

  • @TheGmr140
    @TheGmr140 2 года назад +1

    Thank you , this video helped me with images processing. Great channel

  • @System-1541
    @System-1541 3 года назад

    Very nicely explained video! You clearly know your stuff!

  • @chiranjeebroychowdhury7759
    @chiranjeebroychowdhury7759 3 года назад +1

    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*

  • @yoniziv
    @yoniziv 2 года назад

    Thanks so much for the great content you're sharing!

  • @iansjackson
    @iansjackson 3 года назад

    All other brilliance aside, also absolutely impressed with your knowledge of Rolling Stones lyrics ;)

  • @codingelle
    @codingelle 3 года назад

    love it 😍 thanks for sharing

  • @chriswarburton71
    @chriswarburton71 3 года назад

    Clear and perfect pace for me, thanks .. sub

  • @rbk00006
    @rbk00006 3 года назад +7

    Oh look.. it's my favorite python teacher.

    • @PythonSimplified
      @PythonSimplified  3 года назад +1

      Thank you so much for your support Rishabh! I'm always so happy to see your comments! :D

  • @JuanGabrielOyolaCardona
    @JuanGabrielOyolaCardona Год назад

    Thank you so much 🥰❤️

  • @romirmathur6540
    @romirmathur6540 3 года назад +1

    Great lectures.... 👌Really enjoyed them

    • @PythonSimplified
      @PythonSimplified  3 года назад +1

      Thank you Romir, I'm glad you liked them!! 😁

  • @beatricedale1581
    @beatricedale1581 Год назад

    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

  • @louaykhammar7268
    @louaykhammar7268 2 года назад

    very helpful tutorial

  • @lancemarchetti8673
    @lancemarchetti8673 4 месяца назад

    Brilliant

  • @ashashaikh3421
    @ashashaikh3421 3 года назад +3

    Enjoyed watching ur vedio mam, keep up ur good work like this. Thank you

    • @ashashaikh3421
      @ashashaikh3421 3 года назад

      Lot of respect from India. Really appreciate ur work

    • @PythonSimplified
      @PythonSimplified  3 года назад +1

      @@ashashaikh3421 Thank you so much Farzanna! I really appreciate your kind words and sending you lots of love all the way from Canada :) Namaste!

  • @amanrubey
    @amanrubey 2 года назад

    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 😊

  •  2 года назад

    Very good video!
    What is the difference between pillow and processing-py?

  • @gaddamshanthsri125
    @gaddamshanthsri125 3 года назад

    Nice tutorial

  • @losaminos59
    @losaminos59 2 года назад

    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.

  • @maksymilianyurchenko4231
    @maksymilianyurchenko4231 3 года назад +3

    That Lady is what every (and not only) python programmer is looking for. Amazing

  • @walidslimani2336
    @walidslimani2336 3 года назад

    Great

  • @Packer_Games
    @Packer_Games 23 дня назад

    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.

  • @magiczico
    @magiczico 2 года назад

    ty

  • @piero1234567891
    @piero1234567891 3 года назад +1

    nice job!

  • @anjanbora7943
    @anjanbora7943 Год назад

    ❤️

  • @TheMarbo74
    @TheMarbo74 3 года назад +2

    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

    • @PythonSimplified
      @PythonSimplified  3 года назад +3

      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! 😃

    • @fab_code
      @fab_code 3 года назад

      @@PythonSimplified notebook users are cheating

  • @daviddewortor09
    @daviddewortor09 Год назад

    How can I employ python pillow library in autolisp programming for kml file extraction?

  • @rezwanrashid4518
    @rezwanrashid4518 3 года назад +2

    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?!

    • @PythonSimplified
      @PythonSimplified  3 года назад +1

      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

    • @rezwanrashid4518
      @rezwanrashid4518 3 года назад

      @@PythonSimplified thank you miss ..u explain everything so easily that everything is simplified :)

  • @nocontent3124
    @nocontent3124 3 года назад

    Explain Pillow versus PIL. Also good job, subbed.

    • @cferracini
      @cferracini 3 года назад

      if i'm not mistaken PIL has not been updated in years, so basically pillow is the substitute for PIL that still has support

    • @404errorpagenotfound.6
      @404errorpagenotfound.6 3 года назад

      @@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.

  • @davidtorre7842
    @davidtorre7842 3 года назад

    Buen video :)

  • @Mayank-lf2ym
    @Mayank-lf2ym 2 года назад +1

    Mam how to overlay a image with less opacity in python pillows please answer

  • @anburenganathan8369
    @anburenganathan8369 3 года назад

    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

  • @romirmathur6540
    @romirmathur6540 3 года назад +1

    Ma'am can you make playlists on open cv, tensorflow and more stuff like that.

    • @PythonSimplified
      @PythonSimplified  3 года назад +1

      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! :)

  • @Leon-vvah-vvah
    @Leon-vvah-vvah 3 года назад +2

    I ❤️ Python.. but I ❤️ Mariya more..😁

  • @himanshupanwar8754
    @himanshupanwar8754 3 года назад

    noice

  • @nooralaa987
    @nooralaa987 3 года назад +1

    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 .

    • @PythonSimplified
      @PythonSimplified  3 года назад

      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_am_a_real_cat1443
    @i_am_a_real_cat1443 2 года назад

    I love girls who can code. I love when they programm the oven or the other kitchen supplies.

  • @bruhlickd
    @bruhlickd 2 года назад +1

    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?

    • @PythonSimplified
      @PythonSimplified  2 года назад +2

      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

    • @bruhlickd
      @bruhlickd 2 года назад

      ​@@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?

  • @riyapalkar1178
    @riyapalkar1178 3 года назад

    Hi , plzs tell how to open any image in Tkinter without specifying its name

  • @kuaranir2440
    @kuaranir2440 2 года назад

    Please make a tutorial how to create train val test dataset of images🙏

  • @sincelife5141
    @sincelife5141 3 года назад +1

    Maria your thumbnail is hilarious

    • @PythonSimplified
      @PythonSimplified  3 года назад

      Thank you! 😁
      It's the first thing that came to my mind when thinking about pillow 🤣 hahaha

  • @daviderivona6576
    @daviderivona6576 2 года назад

    Could you convert an Image to its numerical base code, pls?

  • @marcoslucio8244
    @marcoslucio8244 Год назад

    Você é brasileira reconheci pelo sotaque!

  • @abhaysharma1139
    @abhaysharma1139 3 года назад +1

    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

    • @PythonSimplified
      @PythonSimplified  3 года назад +1

      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! 😉

    • @abhaysharma1139
      @abhaysharma1139 3 года назад +1

      @@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

    • @souvikghosh6966
      @souvikghosh6966 2 года назад

      @@abhaysharma1139 age doesn't matter when it comes to learning..

  • @angelferhati
    @angelferhati 2 года назад

    Can I Display video with pil

    • @PythonSimplified
      @PythonSimplified  2 года назад +1

      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! 😀

  • @fab_code
    @fab_code 3 года назад +1

    me: woah i didn't know a girl programmer existed
    mariya: yes

  • @mmaxeator
    @mmaxeator 3 года назад

    AI and PS still on taskbar :-)

  • @leihejun844
    @leihejun844 2 года назад

    11:43 well it's _monochromic_ to be exact.

  • @jonyjohan8958
    @jonyjohan8958 3 года назад +1

    ModuleNotFoundError: No module named 'PIL' ..... i have python 3.9

    • @PythonSimplified
      @PythonSimplified  3 года назад +3

      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

    • @jonyjohan8958
      @jonyjohan8958 3 года назад +1

      i will down grade to python 3.8 thank you very much for advice 👍🏼 @@PythonSimplified

  • @plushfly900
    @plushfly900 3 года назад

    Oo nice girl)

  • @yashvanderbamel
    @yashvanderbamel 2 года назад

    6:34 oh finally you switched to a different cell. You look like a .py user more than a .ipynb one 😜

  • @modelworkzseo
    @modelworkzseo 2 года назад

    Thank you for the erection; I mean explanation. Really helped my confinement time pass faster.

  • @felizcreations23
    @felizcreations23 3 года назад

    Video processing 😟

  • @aare5056
    @aare5056 Год назад

    Can I get a job with turtle drawing along

  • @SchonGetestet
    @SchonGetestet 3 года назад +1

    are you also russian? :)

    • @PythonSimplified
      @PythonSimplified  3 года назад +2

      I sure am! 😃
      (originally from Crimea, but I've immigrated twice since, therefore the exotic accent 🤣)

  • @maamounhajnajeeb209
    @maamounhajnajeeb209 2 года назад

    Arabic Subtitle, Thank You