Digital Image Processing - a practical approach

in #steemstem6 years ago

An image is an optical representation of an object illuminated by a radiation source. A digital image is defined as the function of real variables having a precise amplitude (brightness, contrast, etc.) and coordinate position.

Conceptual image from Pixabay

In electrical and computer engineering, image processing is a form of signal processing that uses an image as the input signal. The output of image processing can be a set of characteristics or an entire image. Image processing technology can be broadly classified into three categories:

  • Analog Image Processing
  • Optical Image Processing
  • Digital Image Processing
  • Analog image processing is used in television broadcasting through dish antenna systems and is standard in older television models. Signals are received in analog form having the characteristics of phase shift and phase difference in analog image processing system.

    Optical image processing techniques are used in microscopes and telescopes to visualize and enhance a specific object. A combination of lenses are used in specific orientation to perform precise operations.

    Digital Image Processing

    Digital image processing (DIP) involves treating an input image as a discrete signal and applying standard signal processing algorithms to perform specific operations. DIP is the most advanced branch of modern image processing technology. Generally speaking, the input signal is analyzed with the following operations:

    Image Acquisition

    The very first step of DIP is image acquisition where the input image is captured by a scanner or digital camera module. Image acquisition may also include some pre-processing techniques such as enhancement, color model conversions, etc. Enhancement techniques emphasize specific characteristics of the input image while color model conversions modify the colors of the image.

    Figure 1: Schematic diagram of image processing, by the author


    Segmentation is the process of partitioning the input image into integral parts. This is one of the most challenging parts of DIP. The segmentation procedure is accomplished by scanning the image pixel by pixel and quantifying each based on a specific threshold value.


    The raw pixel data output from segmentation is used in the representation step. Analysis of corners and inflection is done using boundary representation and edge detection. Regional representation of the entire image is required to perform an analysis on textural or skeletal shapes.


    A mathematical, model-based restoration technique is used to enhance the quality of the processed image. Filters (Gaussian, Convolution, etc.) provide convenient methods of image restoration. A brilliant article by @terrylovejoy about the effective use of filters in astrophotography can be read here.

    Output Evaluation

    There are several image processing algorithms that can be used to evaluate the output image. The characteristics of the output can also be gathered for further analysis such as face detection or fingerprint recognition.

    DIP System Components

    A variety of components are required to make DIP systems functional. The fundamental elements of a DIP system are:

    1. Image sensor4. Sufficiently powerful hardware
    2. Computational device5. Image processing software
    3. Display device6. Networking equipment

    The acquisition of digital images is commonly done with the help of a digital camera. The camera sensors generate electrical outputs that are converted into discrete signals. Computational devices are required to analyze the acquired data using specific algorithms. Specialized image processing hardware is often necessary to achieve a desired level of performance.

    Software designed especially for image processing is a core component of DIP systems. OpenCV, ImageJ, Matlab, and eFilm are a few of the most commonly used image processing software packages. These packages support a variety of different programming languages like C, C++, Python, Java, etc. Matlab is widely used in electrical engineering while eFilm is popular for biomedical image analysis. Image displays and networking equipment are also essential components of a practical DIP system.

    DIP Applications

    Digital image processing can be applied to help solve problems in a wide range of diciplines. Researchers are continually trying to develop new algorithms to improve image processing. Some common applications of DIP include digital video processing, face detection, machine learning, biometric verification, remote sensing, computer vision, pattern and signature recognition, astrophotography, biomedical image analysis, and control robotics.

    A detailed discussion on the applications of DIP will be provided in upcoming chapters of this series. Today, we will start by looking at a simple example of DIP.

    Shape Identification using DIP in Matlab

    The concept of digital image processing can easily be discussed with a practical example. As stated earlier, DIP can be done using any of the most widely used programming languages. Numerous software and processing techniques are used in DIP and there are dedicated software packages such as ‘Adobe Photoshop’ or 'GIMP' that can process digital images in a multitude of ways.

    Matlab is a numerical computing environment for engineering and scientific research analysis that uses a matrix based high performance programming language known as "Matlab language". Digital image processing operations are performed in Matlab with the help of built-in functions. The objective of this image processing analysis is to identify the roundness of different shapes. This simple task will be demonstrated using Matlab. The following figure will be used as it contains several uniquely shaped objects.

    Figure 2: Sample image from Pixabayunder CC 0

    Begin by changing the ‘current folder directory’ in Matlab to the local folder containing the sample image. Acquisition of the image is done using the imread function. In this case, the processed image is assigned the variable name ‘sample’. The sample image is then converted to grayscale with the help of rgb2gray function, as shown in Figure 3.

    Figure 3: Grayscale conversion in Matlab.

    Next, the grayscale image is converted to black and white so that boundary representation can be applied. Objects smaller than a 50-pixel threshhold are ignored to reduce the noise.

    Figure 4: Black & white conversion with noise reduction.

    Only the outer edges of the shapes are considered and each boundary is drawn within a matrix. A thin white colored boundary line is plotted around each object to highlight the boundary region. The threshold value is set as high as 0.98 to obtain an accurate identification.

    Figure 5: Boundary operation.

    The area and perimeter of each object is calculated using the respective formulas (provided below). A metric was formed to estimate roundness by determining the shape of the object relative to a perfect circle. The acquired data is then plotted to generate a digitally processed output image.

    Figure 6: Metric formation and plotting.

    Figure 7 shows the output image labelled with the calculated value of roundness. The more circular objects have numbers closer to 1.0.

    Figure 7: Digitally processed output image.


    Digital image processing is becoming one of the most important branches of industrial production technology. The implementation of controlled robotics algorithms in DIP technology is helping to increase production efficiency. Biometric verification algorithms with improved accuracy are also being developed based on enhanced image processing.

    From urban traffic control systems to astrophotography, image processing is ubiquitous in modern civilization. The major drawback of this technology at present is the limitation of image resolution quality. The viewing angle and the optics and hardware of the camera have a significant impact on the processed result. Ongoing advanced research is expected to further mitigate this hurdle with improved image acquisition technologies.

    A wide range of software environments can be used to perform DIP. In this article, I used Matlab programming language to evaluate a fundamental operation of shape identification. Matlab R2017a was used to create this programming environment. The complete code of the program is provided below:

    sample = imread('g5.png');
    I = rgb2gray(sample);
    bw = imbinarize(I);
    bw = bwareaopen(bw,50);
    imshow(label2rgb(L, @jet, [.5 .5 .5]))
    hold on
    for k = 1:length(B)
      boundary = B{k};
      plot(boundary(:,2), boundary(:,1), 'w', 'LineWidth', 2)
    stats = regionprops(L,'Area','Centroid');
    threshold = 0.98;
    for k = 1:length(B)
      boundary = B{k};
      delta_sq = diff(boundary).^2;    
      perimeter = sum(sqrt(sum(delta_sq,2)));
      area = stats(k).Area;
      metric = 4*pi*area/perimeter^2;
      metric_string = sprintf('%2.2f',metric);
    title(['Digitally processed output image for steemSTEM']);

    More image processing algorithms using Matlab can be found here.


    [1] D.S. Sohi, S.S. Devgan, “Application to enhance the teaching and understanding of basic image processing techniques”, IEEE Southeastcon 2000, iEEE Xplore, Accessed on 25th May, 2018.
    [2] Yi Lei, Yabo Chen, “Optimization of Specific Instruction Set Processor for Image Algorithms”, Procedia Computer Science, V. 131, P. 182-191, ScienceDirect, Accessed on 25th May, 2018.
    [3] M. Ekstrom, “Digital Image Processing Techniques”, Textbook by Elsevier, Accessed on 26th May, 2018.
    [4] A. McAndrew, “An Introduction to Digital Image Processing with Matlab”, Notes for SCM2511 Image Processing 1, Course document of Victoria University of Technology, Accessed on 26th May, 2018.
    [5] A. Mohan, S. Poobal, “Crack detection using image processing: A critical review and analysis”, Alexandria Engineering Journal, ScienceDirect, Accessed on 26th May, 2018.
    [6] D N Kumar, “Image Processing Using MATLAB”, IISc, Bangalore, Web document, Accessed on 26th May, 2018.
    [7] V. K.Pepper, C.Francom et al., “Objective characterization of airway dimensions using image processing”, International Journal of Pediatric Otorhinolaryngology, ScienceDirect, Accessed on 26th May, 2018.

    Software Resources

  • OpenCV
  • ImageJ
  • Matlab
  • eFilm
  • Adobe Photoshop
  • GIMP

  • Many thanks to @gra for the support in mentoring this article.

    If you are interested in reading or writing Science, Technology, Engineering and Math related articles on steemit, feel free to join us in the steemSTEM community! Find more about steemSTEM from here, or visit the official discord server.

    gif credit goes to @rocking-dave


    Wow @christinaa this is incredible! By reading your article about digital image processing, I've learned a lot about its uses in our world. I hope it improves, and I hope the picture quality improves. Keep up your personal and STEM articles! Good to have you in my feed!

    Thanks man..!!! Good to see u reading my articles.. :)

    This is very cool @christinaa and thanks for the shoutout! I haven't got matlab but I'm may try to port some of your samples into C# or Python, so it's good you post the code blocks here. I'm really looking forward to your series.

    I will be showing my age here, but many of the image processing techniques started with film. For example unsharp masking was done by taking out-of-focus copy of a negative and then using that as a mask in front of the original negative to sharpen a image. Photographic dodging was another technique where you'd get a paper-clip with a bit of putty on the end as a blocking tool to fade out parts of the image when you printed it in an enlarger. Of course hardly anyone would do it this way now...

    Ur articles are really amazing, terry.. When I was writing about filters, I immediately recall about ur post and im glad to mention it here... I will continue this series of image processing hopefully... U can use OpenCV for ur C# or python codes..
    U r absolutely right.. The idea of processing images to a desired level is really old concept.. As u said, back in the days of 'films' people used to modify images manually and thanks to the advancement of technology, we can do this with righting a few blocks of codes today...!
    Thanks for ur compliments.. :)

    Good tip about OpenCV ! Found Emgu which is a .NET port for OpenCV so looks like I might be playing with that in the near future.

    cool..!! hope to see more amazing post about image processing from u..!

    I guess I would say I understand a bit of DIP now but I stopped reading at the point where the coding started 😂. I know nothing about coding
    Thanks for sharing this @christinaa

    hehehe.... If u ever used a photo editing software in ur phone or pc, u understand DIP... :p Coding isnt always necessary in DIP, we have software like photoshop that can do a great image processing task..!
    Thanks for ur compliments, dear.. :)

    DIP is a vast field. You have pretty much summed up the whole idea of it in this post, brilliantly.
    Would you be writing more about it? Like discussing each phase of DIP?
    I started the series as well and have managed to done only two articles on it so far.

    I think i will continue this series with more examples and explanation about DIP applications.. I saw ur latest post about encryption issues, its great..!
    And thanks for ut compliment, man.. :)

    That would be great. Looking forward to your next post.
    Thanks for the appreciation.

    Although I have been photographing and processing photos for a very long time, I only knew a small part of what you wrote in the article. Congratulations !

    A photographer like u definitely have a vast experience on image processing things.. I just discussed about another way of processing the image..
    Thanks btw.. :)

    just awesome. i tried to figure out about image processing because i so much excited to do some research on lab for a IEEE publication. This article help me understanding the importance image processing .This is an inspirational work for me. great work @christinaa

    thanks for ur compliment.... :)

    This is very important for me. I really cant be exposing my reasons

    Thanks for this...... I might be needing Matlab tutorials from you #winks

    hehe.. im not a master on matlab.. bt if u need something, feel free to contact me.. I would be glad to help if i can.. :)

    Hi @christinaa!

    Your post was upvoted by in cooperation with steemstem - supporting knowledge, innovation and technological advancement on the Steem Blockchain.

    Contribute to Open Source with

    Learn how to contribute on our website and join the new open source economy.

    Want to chat? Join the Utopian Community on Discord

    Congratulations @christinaa! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

    Award for the number of upvotes

    Click on any badge to view your Board of Honor.
    For more information about SteemitBoard, click here

    If you no longer want to receive notifications, reply to this comment with the word STOP

    Do not miss the last announcement from @steemitboard!

    Do you like SteemitBoard's project? Vote for its witness and get one more award!

    This goes beyond my skills. I do some art, web design, photo editing, video editing, but I don't know a lot of code. This is interesting.

    this is another way of image processing, what u do is also a way.. :p

    Coin Marketplace

    STEEM 0.28
    TRX 0.12
    JST 0.032
    BTC 67333.93
    ETH 3115.87
    USDT 1.00
    SBD 3.73