great place to work

Digital Image Processing for Real-time Decision Making


Digital Image Processing

Digital technologies, tools and platforms are playing a pivotal role in improving business decision making across all areas. Image processing is one such area where digitization is helping businesses take decisions in real-time for multiple scenarios and use cases. In this article we will deep dive into how we can leverage MATLAB for image processing along with a use case.

First, let’s define an image for this article. An image is defined as a Matrix M(x,y), where x and y are the coordinates -a pair of coordinates (x,y) is called the intensity of that image at that point. In other words, an image can be defined by a Matrix specifically arranged in rows and columns.

The manipulation of images using algorithms is known as Digital Image Processing. MATLAB is the most common software used for Digital Image processing, which is primarily used to gather critical information from images. There are lot of algorithms available for image processing.

Understanding Image Processing with an Example

We can understand the idea of image processing with a real-time example. Consider a traffic image which is given below.

fig 1

Fig 1: A Picture of Traffic Signal in Kochi, India

We can use this image to determine the density of traffic. The density of the traffic is determined by following steps:

First, we take a reference image. In naïve background subtraction method, the level of traffic is detected by subtracting the real-time frame from the reference frame, which is simply an image that depicts the road when it is empty.

Fig 2

Fig 2: A Reference Image

First, these frames are converted to grayscale using weighted mean method. The formula for obtaining the gray scale image is:

New gray scale image = ((0.3 * R) + (0.59 * G) + (0.11 * B))

Where, R = red channel

G = green channel

B = blue channel

When the frames are compared in their entirety, environmental conditions can affect the result drastically. Thus, only the Region of Interest (ROI) or Masking is taken, i.e., only the road is considered.

Fig 3

Fig 3: Lane After Masking the Grayscale

The real-time image is then subtracted from the reference frame. The resultant image would only contain the vehicles that are on the road.

Fig 4

Fig 4: After Removing Real-time Image

This image is then converted to binary to calculate the threshold value (t) for determining the level of traffic.

Fig 5

Fig 5: Binary Image

The level of traffic is determined as follows:

Table 1

Algorithm Flowchart to Find the Traffic Density

The flowchart given below shows the overview of the algorithm which we are using to find the traffic density at the same place over different times in a day.

Fig 6: Algorithm Flowchart

Calculating Traffic Density using MATLAB GUI

First we should take a picture of the required location/road without any vehicles. The picture we have taken contains many unwanted information, but we require only the picture of road. So we can remove other unwanted information from the picture. Then, we will convert the picture into the binary format. From the binary we will find a threshold value.

Fig 7: The MATLAB Simulation using the Images

Next, we can take a picture of a road with traffic. The picture we have taken again, contains many unwanted information but we only need the picture of road to ascertain the traffic. So, we will remove other unwanted information from the picture.  Then, we will convert the picture into a binary format. As we did earlier, from the binary we can find a threshold value.

Fig 9

Fig 8: The MATLAB Simulation using the Images

The final step is to compare both threshold values and present the decision according to the threshold difference, on whether there is low traffic, medium or high traffic on the road.

We have just seen how implementing image processing for traffic analysis, can help us take decisions in the real-time. Digital image processing can be applied to other areas as well. For example, we can use this approach to detect the number of people standing in a queue in front of an ATM at different times in a day. This would help us to determine if an additional ATM machine is required in the same location. We can leverage digital image processing similarly for several business scenarios and use cases and arrive at critical business decisions in the real-time, which would further improve business performance and customer experience.

Aleena Shaju
Software Engineer, RapidValue

Please Share Your Thoughts & Comments Below.

How can we help you?