This GUI loop blocks your scripts and they are paused until the last figure window is closed. The show() command starts the figure GUI and raises the figure windows. This plots the image, then four points with red star markers at the x and y coordinates given by the x and y lists, and finally draws a line (blue by default) between the two first points in these lists. # line plot connecting the first two points Here is an example of plotting an image with a few points and a line: from PIL import Image Most importantly, we want to be able to show things like interest points, correspondences, and detected objects using points and lines. Return Īlthough it is possible to create nice bar plots, pie charts, scatter plots, etc., only a few commands are needed for most computer vision purposes. """ Returns a list of filenames for all jpg images in a directory. Create a file called imtools.py to store some of these generally useful routines and add the following function: import os Here’s how you could create a list of filenames of all images in a folder. Throughout this book we are going to need lists of images to process. There is a simple check that the file is not already a JPEG file and a message is printed to the console if the conversion fails. PIL is smart enough to determine the image format from the file extension. The new filename will be the same as the original with the file ending “.jpg” instead. The PIL function open() creates a PIL image object and the save() method saves the image to a file with the given filename. Outfile = os.path.splitext(infile) + ".jpg" Figure 1-1. Examples of processing images with PIL.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |