Image captioning is a very classical and challenging problem coming to Deep Learning domain, in which we generate the textual description of image using its property, but we will not use Deep learning here. In this article, we will simply learn how can we simply caption the images using PIL.
Preprocessing on images is a great utility provided by Python PIL library. Not only we can change size, mode, orientation but we can draw on images, write text over it as well.
Install the required libraries:
urllib requests PIL glob shutil
Steps to follow first –
- Download the
font.ttffile (before running the code) using this link.
- Make folder with name as “CaptionedImages” beforehand where the output captioned images will be stored.
Below is the stepwise implementation using Python:
Sorting the output files in accordance to last modified time so that they do not get placed in alphabetical or any other mismanaged order.
- Getting started with Scikit-image: image processing in Python
- Converting an image to ASCII image in Python
- Image Processing in Java | Set 6 (Colored image to Sepia image conversion)
- Image Processing in Java | Set 3 (Colored image to greyscale image conversion)
- Image Processing in Java | Set 4 (Colored image to Negative image conversion)
- Python PIL | Image.tell()
- Python PIL | Image.getdata()
- Python PIL | Image.histogram()
- Python PIL | Image.new() method
- Image Translation using OpenCV | Python
- Python PIL | Image.save() method
- Python | Image Classification using keras
- Python PIL | Image.open() method
- Python PIL | Image.split() method
- Python PIL | Image.point() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.