Support Statistics
¥.00 ·
0times
Text Preview (First 20 pages)
Registered users can read the full content for free
Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.
Page
1
(This page has no text content)
Page
2
(This page has no text content)
Page
3
Digital Image Processing Using Python A comprehensive guide to the fundamentals of digital image processing Dr. Manish Kashyap www.bpbonline.com
Page
4
First Edition 2025 Copyright © BPB Publications, India ISBN: 978-93-65898-910 All Rights Reserved. No part of this publication may be reproduced, distributed or transmitted in any form or by any means or stored in a database or retrieval system, without the prior written permission of the publisher with the exception to the program listings which may be entered, stored and executed in a computer system, but they can not be reproduced by the means of publication, photocopy, recording, or by any electronic and mechanical means. LIMITS OF LIABILITY AND DISCLAIMER OF WARRANTY The information contained in this book is true to correct and the best of author’s and publisher’s knowledge. The author has made every effort to ensure the accuracy of these publications, but publisher cannot be held responsible for any loss or damage arising from any information in this book. All trademarks referred to in the book are acknowledged as properties of their respective owners but BPB Publications cannot guarantee the accuracy of this information. www.bpbonline.com
Page
5
Dedicated to My family and The only truth I know – Krishna
Page
6
About the Author Dr. Manish Kashyap is an Assistant Professor at Maulana Azad National Institute of Technology Bhopal (NIT Bhopal). He received his Ph.D. in image processing in 2017 from the Indian Institute of Information Technology and Management Gwalior (IIIT Gwalior). Dr. Kashyap completed his M.Tech and B.Tech in Electronics and Communication Engineering from Jaypee Institute of Information Technology, NOIDA in 2013 and 2009, respectively. He has authored a good number of research papers in Scientific Citation Indexed and SCOPUS- indexed journals and conferences. His primary objective is to make technical subjects more accessible and understandable for students and readers through his lectures, research papers, articles, and books.
Page
7
About the Reviewers Dr. Ravi Shanker completed his PhD from the Atal Bihari Vajpayee Indian Institute of Information Technology and Management (ABV-IIITM), Gwalior. He has gained research experience through a DST-SERB-sponsored project at institutes of national importance. As a researcher, he has developed various computer-assisted diagnostic (CAD) systems for classifying brain MRI images. Dr. Shanker has published articles in SCIE journals, authored book chapters, and presented papers at various international and Scopus-indexed conferences. He also serves as a reviewer for multiple SCIE and Scopus-indexed journals, including The Journal of Supercomputing, Concurrency and Computation: Practice & Experience, IEEE Access, and the International Journal of Imaging Systems and Technology. Currently, he works as an Assistant Professor at the Indian Institute of Information Technology, Ranchi. Shekhar is a Senior Data Scientist based in Hamburg, Germany, with 15 years of expertise in AI and machine learning. He earned his Master's in Data Science with distinction, conducting pioneering research in computer vision. His work has been featured in prominent deep- learning publications, establishing him as an industry thought leader. His technical expertise spans AWS, Google Cloud, Azure, and IBM Cloud, where he excels at implementing enterprise- scale AI solutions. In his current role, he leads innovation in
Page
8
generative AI, focusing on large language model fine-tuning, RAG systems, and AI agent orchestration. He also specializes in integrating these technologies into enterprise systems to develop production-ready applications that deliver tangible business value. As a technical leader, he builds and mentors high- performing data science teams while implementing MLOps best practices. His leadership style combines technical depth with business acumen, enabling organizations to successfully navigate AI transformation. Outside of work, Shekhar is an avid CrossFit enthusiast, cyclist, and marathon runner. His comprehensive understanding of AI theory and practice, particularly in generative AI, makes him a sought-after technical reviewer and industry expert.
Page
9
Acknowledgement I want to express my deepest gratitude to my family and friends for their unwavering support and encouragement throughout this book's writing, especially my mother. I am also grateful to BPB Publications for their guidance and expertise in bringing this book to fruition. It was a long journey of revising this book, with valuable participation and collaboration of reviewers, technical experts, and editors. I would like to acknowledge the invaluable contributions of my colleagues and co-workers throughout my years in academia, who have taught me so much and provided valuable feedback on my work. Finally, I would like to thank all the readers for their interest in my book and their support in making it a reality. Your encouragement has been truly invaluable.
Page
10
Preface In the rapidly evolving field of digital image processing, Python has emerged as a powerful and accessible tool for tackling complex problems and bringing innovative solutions to life. This book, Digital Image Processing Using Python, is designed to provide a comprehensive and practical introduction to this dynamic field. Whether you are an undergraduate student, a master’s level scholar, or a research professional, this book offers valuable insights and hands-on experience in image processing. The primary goal of this book is to bridge the gap between theoretical concepts and practical applications. Each chapter is meticulously crafted to explain fundamental image processing techniques while integrating real-world Python code examples. These examples are intended to reinforce your understanding and provide you with the skills to implement these techniques in various scenarios. By working through these examples, you will understand how to manipulate and analyze digital images effectively. As you progress through this book, you will not only learn about the core principles of image processing but also how to apply them using Python’s powerful libraries. The practical approach adopted here is aimed at making complex concepts more accessible and relatable. We hope this book will serve as a valuable resource for those looking to advance their knowledge and skills in image processing, and inspire you to explore further into this exciting field. The book covers the following chapters:
Page
11
Chapter 1: Introduction to Digital Images - This chapter covers the foundational concepts of digital images, detailing their structure, representation, and the role of pixels in image data. It covers the essential principles that define digital images, providing a thorough understanding necessary for advanced image processing techniques. This introduction is crucial for grasping the complexities of image manipulation and sets the groundwork for subsequent chapters on practical applications and Python implementations Chapter 2: Python Fundamental and Related Libraries - This chapter covers the core Python programming concepts and libraries essential for digital image processing. It also covers fundamental Python syntax, data structures, and introduces key libraries such as NumPy, Matplotlib, and OpenCV, which are pivotal for manipulating and analyzing images. By establishing a solid understanding of these tools, this chapter provides the technical foundation required for effectively implementing image processing techniques in later sections of the book. Chapter 3: Playing with Digital Images - This chapter covers practical techniques for interacting with digital images, focusing on manipulating pixels and patches, analyzing pixel neighborhoods, and performing histogram processing. It explores basic transformations applied to images and introduces various color models essential for understanding image representation. This chapter aims to equip readers with hands-on experience in fundamental image processing tasks, setting the stage for more advanced manipulations and analyses. Chapter 4: Spatial Domain Processing - This chapter covers the principles of spatial domain image processing, beginning with one-dimensional signals and systems. It includes graphical illustrations of one-dimensional
Page
12
convolution and provides an intuitive understanding of filter design. The chapter then extends to two-dimensional filtering, detailing methods for applying filters using Python, and covers both smoothing low-pass filters and sharpening filters. Additionally, it differentiates between convolution and correlation, offering a comprehensive overview of spatial domain techniques essential for effective image manipulation. Chapter 5: Frequency Domain Image Processing - This chapter covers the principles of frequency domain image processing, beginning with the analysis of one-dimensional analog and discrete time signals in both time and frequency domains. It extends to two-dimensional Fourier transforms, detailing their application to image processing. The chapter also covers filtering techniques in the frequency domain, providing a thorough understanding of how frequency-based methods can enhance and manipulate images effectively. Chapter 6: Non-linear Image Processing and the Issue of Phase - This chapter covers non-linear image processing techniques and the concept of phase in image analysis. It covers median filtering in the spatial domain for removing salt-and-pepper noise and addresses the conversion of continuous data to discrete formats, including the sampling theorem. Additionally, the chapter explores homomorphic filtering, the role of phase in image processing, and selective filtering methods, providing a comprehensive understanding of advanced techniques for image enhancement and noise reduction. Chapter 7: Noise and Image Restoration - This chapter covers noise and degradation in images, starting with an overview of noise and degradation models. It covers techniques for image restoration in the presence of noise, including methods for detecting and measuring noise using PSNR. The chapter also explores classical noise removal
Page
13
methods and adaptive filtering techniques, offering a thorough understanding of strategies to improve image quality and restore clarity amidst noise. Chapter 8: Wavelet Transform and Multi-resolution Analysis - This chapter covers wavelet transforms and multi-resolution analysis, beginning with the impact of resolution on frequency content and the trade-offs between time and frequency resolution. It addresses the loss of location information in the frequency domain and introduces the short-time Fourier transform. The chapter covers key concepts such as scale, scalogram, and both continuous and discrete wavelet transforms. Additionally, it explores multi- resolution analysis techniques using wavelets and their applications for noise removal, providing a comprehensive understanding of advanced methods for analyzing and processing image data. Chapter 9: Binary Morphology - This chapter covers the essential concepts and techniques of binary morphology, focusing on operations such as erosion and dilation, and their duality. It explores advanced morphological processes including opening and closing, hit-and-miss transform, and boundary extraction. The chapter also addresses hole and region filling, connected component analysis, and its implementation using the image library. Additional topics include convex hull, thinning, thickening, and skeletonization, providing a comprehensive guide to manipulating and analyzing binary images through morphological techniques.
Page
14
Code Bundle and Coloured Images Please follow the link to download the Code Bundle and the Coloured Images of the book: https://rebrand.ly/90b15f The code bundle for the book is also hosted on GitHub at https://github.com/bpbpublications/Digital-Image- Processing-Using-Python. In case there’s an update to the code, it will be updated on the existing GitHub repository. We have code bundles from our rich catalogue of books and videos available at https://github.com/bpbpublications. Check them out! Errata We take immense pride in our work at BPB Publications and follow best practices to ensure the accuracy of our content to provide with an indulging reading experience to our subscribers. Our readers are our mirrors, and we use their inputs to reflect and improve upon human errors, if any, that may have occurred during the publishing processes involved. To let us maintain the quality and help us reach out to any readers who might be having difficulties due to any unforeseen errors, please write to us at : errata@bpbonline.com
Page
15
Your support, suggestions and feedbacks are highly appreciated by the BPB Publications’ Family. Did you know that BPB offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.bpbonline.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at : business@bpbonline.com for more details. At www.bpbonline.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on BPB books and eBooks. Piracy If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at business@bpbonline.com with a link to the material. If you are interested in becoming an author If there is a topic that you have expertise in, and you are interested in either writing or contributing to a book, please visit www.bpbonline.com. We have worked with thousands of developers and tech professionals, just like you, to help them share their insights with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea. Reviews Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions. We at BPB can understand what you think about our products, and our authors can see your feedback on their book. Thank you! For more information about BPB, please visit www.bpbonline.com. Join our book’s Discord space Join the book’s Discord Workspace for Latest updates, Offers, Tech happenings around the world, New Release and Sessions with the Authors:
Page
16
https://discord.bpbonline.com
Page
17
Table of Contents 1. Introduction to Digital Images 1.1 Introduction Structure Objectives 1.1.1 Digital images 1.1.2 Digital image processing 1.2 Grayscale and RGB images 1.2.1 Grayscale image as a two dimensional array of data 1.2.2 RGB colored image 1.2.3 Interpretation of color frames in an RGB image 1.3 Basic image conventions and indexing 1.4 Image formats Conclusion Points to remember Exercises 2. Python Fundamentals and Related Libraries 2.1 Introduction Structure Objectives 2.2 Installing Python software 2.3 General procedure for installing libraries in Python
Page
18
2.4 Basic language elements of Python 2.4.1 Hello world program 2.4.2 Defining and printing variables 2.4.3 Using IDLE editor in Python 2.4.4 Defining variables, basic math, typecasting, and input/output 2.4.5 List data structure in Python 2.4.6 Tuple data structure in Python 2.4.7 Conditional statements in Python 2.4.8 Loops in Python 2.4.9 Functions and lambdas in Python 2.5 NumPy library 2.5.1 Defining and dealing with one dimensional array 2.5.2 Defining and dealing with two dimensional array 2.5.3 Defining and dealing with three dimensional arrays 2.5.4 Operations on arrays 2.5.5 Important points to remember about arrays 2.6 Matplotlib library 2.6.1 Plotting simple graphs 2.6.2 Making use of subplots 2.7 OpenCV library 2.7.1 Importing and displaying the images in default OpenCV way 2.7.2 Displaying the images using matplotlib’s default way 2.7.3 Creating packages in Python 2.8 Pandas library Conclusion
Page
19
Points to remember Exercises 3. Playing with Digital Images 3.1 Introduction Structure Objectives 3.2 Playing with pixel and patches 3.3 Neighborhood of a pixel 3.4 Histogram processing 3.4.1 Histogram of a grayscale image 3.4.2 Information obtained from histogram 3.4.3 Histogram equalization 3.4.3.1 Mathematical pre-requisite for understanding histogram equalization 3.4.3.2 Histogram equalization on one dimensional data 3.4.3.3 Limitations of histogram equalization in digital data 3.4.4 Histogram matching 3.4.4.1 Defining histogram 3.4.4.2 Mathematical background 3.4.4.3 Implementation details 3.4.4.4 Understanding histogram matching 3.5 Basic transformation on images 3.5.1 Intensity transformations 3.5.1.1 Image negatives 3.5.1.2 Logarithmic transformation 3.5.1.3 Power Law Transformation 3.5.2 Spatial transformations
Page
20
3.5.2.1 Affine transformation 3.5.2.2 Projective transformation 3.6 Color models 3.6.1 RGB color model 3.6.2 Cyan-Magenta-Yellow color model 3.6.3 Hue-Saturation-Intensity color model Conclusion Points to remember Exercises 4. Spatial Domain Processing 4.1 Introduction Structure Objectives 4.2 Signals in one dimension 4.3 Systems in one dimension 4.3.1 Linear systems 4.3.3 Linear time invariant systems in one dimension 4.4 Graphical illustration of one-dimensional convolution 4.5 One dimensional filter design intuition 4.5.1 Averaging filters in one dimension 4.5.2 First order derivative filters 4.5.3 Second order derivative filters 4.6 Concept of two-dimensional filtering of images 4.7 Two-dimensional filtering of images in Python 4.8 Smoothening filters 4.8.1 Averaging filters 4.8.2 Circular filters 4.8.3 Weighted filters
Comments 0
Loading comments...
Reply to Comment
Edit Comment