Image Processing in Python
You may already have experience with some form of image processing in your daily life. When you crop photos, apply filters on Instagram or Snapchat, or use effects like Blur or Sharpen in Photoshop, you are using algorithms that help highlight information that you want your images to convey. In scientific computing, we use image processing to make it easier to make certain measurements or to find something specific of interest within the image. Image processing is important for analyzing information from a variety of instruments, such as MRI machines, microscopes, telescopes, and of course, regular cameras.
Here are some other examples of things we might want to do:
Identifying similarities between images (useful for tasks like Google’s reverse image search)
Make it easier to detect specific objects in an image, such as small, faint exoplanets orbiting a very bright star or a tumor in an MRI.
Analyzing changes between images. This might be used to track how something like a bacterium is moving in a video (which is essentially a series of images), or to look for new objects that might have appeared in the sky.
Make measurements or count objects. Perhaps you’re interested in how large a galaxy is, or how many people are in an image.
Can you think of some other ways that image processing may be useful?
Take note of the picture above. Python stores images as arrays. Each pixel of the image is associated with a y-coordinate and an x-coordinate. Notice that the vertical coordinate comes first here, which is the opposite of how you’re probably used to writing coordinates in math class. The origin of the plot is in the upper left corner, which is probably different from the typical xy-plane that you're used to, which has the origin in the lower left corner. Remember that Python is zero-indexed, so the first pixel is pixel 0, not pixel 1.
Understanding how to read these types of charts can be challenging. So let's try an exercise. What are the coordinates of the five centers of the petals above?