How To Read An Image From A URL In OpenCV-Python

1 mainReading an image from a file is fairly straightforward in OpenCV-Python. But a lot of times, we would like to read an image from a URL and process it in OpenCV. One way to do it is to download the image, save it as a jpeg file, and then read it in OpenCV. But that’s too tedious! Who wants to do manual labor? Not me! Another way would be to automatically download the image as a jpeg file using wget and then reading it in OpenCV. This is slightly better, but it’s again a roundabout way of doing it because there is an intermediate step of saving the image on disk. How do we circumvent this and directly load an image from a URL into OpenCV-Python?   Continue reading

Understanding Camera Calibration

1 main copyCameras have been around for a long time now. When cameras were first introduced, they were expensive and you needed a good amount of money to own one. However, people then came up with pinhole cameras in the late 20th century. These cameras were inexpensive and they became a common occurrence in our everyday life. Unfortunately, as is the case with any trade off, this convenience comes at a price. These pinhole cameras have significant distortion! The good thing is that these distortions are constant and they can be corrected. This is where camera calibration comes into picture. So what is this all about? How can we deal with this distortion?   Continue reading

What Is Gamma Correction?

1 mainGamma correction is an integral part of all the digital imaging systems, but a lot of people don’t know about it! It is an essential part of all the imaging devices like cameras, camcorders, monitors, video players, etc. It basically defines the relationship between a pixel’s numerical value and its actual luminance. Now wait a minute, why would they be different? Isn’t a pixel’s numerical value supposed to be exactly the same as its luminance? Well, not really! Without gamma, shades captured by digital cameras wouldn’t appear as they did to our eyes. If we fully understand how gamma works, we can improve our exposure technique, along with making the most of image editing. So what is it all about? Why do we need gamma correction at all?   Continue reading

Understanding Gabor Filters

1 mainIn the field of image processing, filters play an extremely important role. If you don’t know what a filter is, you may quickly want to read the wiki article and come back. Otherwise, this post will not make much sense to you. All image processing operations can be viewed as applying a series of filters to an image and transforming it in some way. We do this for a variety of reasons, like understanding the content of images, transforming the images into another domain, detecting the presence of something in the images, and so on. Gabor filter is a particular type of filter, and it happens to be an important one. If you google “Gabor filter”, you will get a lot of articles. So in this post, rather than looking at the mathematics behind it, we will try to understand the underlying concept. Let’s go ahead, shall we?   Continue reading

Reading JPEG Into A Byte Array

Let’s say you are workBits_and_bytesing with images for your project. A lot of times, when you have to work across multiple platforms, the encoding doesn’t remain the same. In these scenarios, you cannot process images directly by treating them like 2D matrices. One of the most common image formats you will comes across is JPEG. If you are working on the same platform using a library like OpenCV, you can directly read JPEG files into 2D data structures. If not, you will have to read it into a byte array, process it and then encode it back. How do we do that?   Continue reading

Histogram Equalization Of RGB Images

contrastWhen you capture an image using your phone in the evening without flash, do you see how the image is a bit on the darker side? When you take an image with too many lights around you, the images becomes a bit too bright. Neither of the two situations gives us a good quality picture. The human eye likes contrast in images. What it means it that the bright regions should be really bright and the dark regions should be really dark. Almost all the apps and services you use today include this functionality, at least the good ones do. So how do we take one of these dark (or bright) images and improve its quality?   Continue reading

Purkinje Effect

mainEver wondered why the colors seem to change at night? For example, if you look at an air painting, you can see how the colors of objects look radically different in very low light just before dawn or dusk. Consider a red rose, for instance. We know that the flower’s petals are bright red against the green of the leaves in daylight. But, take a look at dusk and you will see that suddenly the contrast is reversed, with the red flower petals now appearing dark red or dark warm gray, and the leaves appearing relatively bright. Bright red doesn’t remain bright red anymore, and green doesn’t remain green either. They all become a bit monochromatic and it becomes difficult to separate them. Why does this happen?   Continue reading

Kruithof Curve

mainThis is more of a continuation of my blog post on color temperature. Back when fluorescent light sources first came up, they changed the way humans thought about light and color rendering. A scientist named Arie Andries Kruithof performed some experiments on how the human eye relates the amount of light in a given time of day to the color temperature of the light source, and came up with a theory. As we move through the day, the amount of light we get keeps varying. Typically, human beings like higher color temperature light sources during the daytime hours, and lower color temperature sources once the sun goes down. People in warmer climates tend to favor cooler color temperature sources, and people in colder climates like warmer light. So what does this have to do with the Kruithof curve?   Continue reading

What Is Color Temperature?

mainWait a minute, isn’t “temperature” associated with weather? How can color have temperature? The thing is that color temperature is actually a characteristic of visible light that has several important applications in photography, publishing, and many other fields. We actually see and feel it all the time, it’s just that we don’t realize that we like certain color temperatures more than others. The concept of color is more easily apparent to us. We can see what’s red and what’s blue. There are a lot of characteristics of color that we feel, but don’t realize. So what exactly is color temperature?   Continue reading

Pixelation

mainPixelation is the display of a digitized image where the individual pixels are easily visible to a viewer. This can happen unintentionally when a low-resolution image designed for an ordinary computer display is projected on a large screen. In this situation, each pixel becomes separately viewable. It’s not pretty! Pixelation is also sometimes used to describe the act of turning a printed image into a digitized image file. As the image is captured, it is processed into a vectorized or rasterized file that can be used to illuminate color units (called pixels) on a display surface. So why does it happen? What exactly happens in there?   Continue reading