You are previewing Image Processing and Acquisition using Python.
O'Reilly logo
Image Processing and Acquisition using Python

Book Description

Image Processing and Acquisition using Python provides readers with a sound foundation in both image acquisition and image processing—one of the first books to integrate these topics together. By improving readers’ knowledge of image acquisition techniques and corresponding image processing, the book will help them perform experiments more effectively and cost efficiently as well as analyze and measure more accurately. Long recognized as one of the easiest languages for non-programmers to learn, Python is used in a variety of practical examples.

A refresher for more experienced readers, the first part of the book presents an introduction to Python, Python modules, reading and writing images using Python, and an introduction to images. The second part discusses the basics of image processing, including pre/post processing using filters, segmentation, morphological operations, and measurements. The last part describes image acquisition using various modalities, such as x-ray, CT, MRI, light microscopy, and electron microscopy. These modalities encompass most of the common image acquisition methods currently used by researchers in academia and industry.

Table of Contents

  1. Preliminaries
  2. Series
  3. Dedication
  4. Foreword
  5. Preface
    1. Audience
    2. Acknowledgments
  6. Introduction
    1. Details about exercises
  7. About the Authors
  8. List of Symbols and Abbreviations
  9. Part I: Introduction to Images and Computing using Python
    1. Chapter 1: Introduction to Python
      1. 1.1 Introduction
      2. 1.2 What is Python?
      3. 1.3 Python Environments
        1. 1.3.1 Python Interpreter
        2. 1.3.2 Enthought Python Distribution (EPD)
        3. 1.3.3 PythonXY
      4. 1.4 Running a Python Program
      5. 1.5 Basic Python Statements and Data Types
          1. Indentation
          2. Comments
          3. Variables
          4. Operators
          5. Loops
          6. if-else statement
        1. 1.5.1 Data Structures
          1. Lists
          2. List functions
          3. List comprehensions
          4. Tuples
          5. Sets
          6. Dictionaries
          7. File handling
          8. Reading CSV files
          9. Reading Excel files
          10. User defined functions
      6. 1.6 Summary
      7. 1.7 Exercises
        1. Figure 1.1
    2. Chapter 2: Computing using Python Modules
      1. 2.1 Introduction
      2. 2.2 Python Modules
        1. 2.2.1 Creating Modules
        2. 2.2.2 Loading Modules
      3. 2.3 Numpy
        1. 2.3.1 Numpy Array or Matrices?
      4. 2.4 Scipy
      5. 2.5 Matplotlib
      6. 2.6 Python Imaging Library
      7. 2.7 Scikits
      8. 2.8 Python OpenCV Module
      9. 2.9 Summary
      10. 2.10 Exercises
        1. Figure 2.1
    3. Chapter 3: Image and its Properties
      1. 3.1 Introduction
      2. 3.2 Image and its Properties
        1. 3.2.1 Bit Depth
        2. 3.2.2 Pixel and Voxel
        3. 3.2.3 Image Histogram
        4. 3.2.4 Window and Level
        5. 3.2.5 Connectivity: 4 or 8 Pixels
      3. 3.3 Image Types
        1. 3.3.1 JPEG
        2. 3.3.2 TIFF
        3. 3.3.3 DICOM
      4. 3.4 Data Structures for Image Analysis
        1. 3.4.1 Reading Images
        2. 3.4.2 Displaying Images
        3. 3.4.3 Writing Images
      5. 3.5 Programming Paradigm
      6. 3.6 Summary
      7. 3.7 Exercises
        1. Figure 3.1
        2. Figure 3.2
        3. Figure 3.3
        4. Figure 3.4
        5. Figure 3.5
        6. Figure 3.6
  10. Part II: Image Processing using Python
    1. Chapter 4: Spatial Filters
      1. 4.1 Introduction
      2. 4.2 Filtering
        1. 4.2.1 Mean Filter
          1. Advantages of the mean filter
          2. Disadvantages of the mean filter
        2. 4.2.2 Median Filter
        3. 4.2.3 Max Filter
        4. 4.2.4 Min Filter
      3. 4.3 Edge Detection using Derivatives
        1. 4.3.1 First Derivative Filters
        2. 4.3.2 Second Derivative Filters
      4. 4.4 Summary
      5. 4.5 Exercises
        1. Figure 4.1
        2. Figure 4.2
        3. Figure 4.3
        4. Figure 4.4
        5. Figure 4.5
        6. Figure 4.6
        7. Figure 4.7
        8. Figure 4.8
        9. Figure 4.9
        10. Figure 4.10
        11. Figure 4.11
        12. Figure 4.12
        1. Table 4.1
        2. Table 4.2
        3. Table 4.3
        4. Table 4.4
        5. Table 4.5
        6. Table 4.6
        7. Table 4.7
        8. Table 4.8
        9. Table 4.9
        10. Table 4.10
    2. Chapter 5: Image Enhancement
      1. 5.1 Introduction
      2. 5.2 Pixel Transformation
      3. 5.3 Image Inverse
      4. 5.4 Power Law Transformation
      5. 5.5 Log Transformation
      6. 5.6 Histogram Equalization
      7. 5.7 Contrast Stretching
      8. 5.8 Summary
      9. 5.9 Exercises
        1. Figure 5.1
        2. Figure 5.2
        3. Figure 5.3
        4. Figure 5.4
        5. Figure 5.5
        6. Figure 5.6
        7. Figure 5.7
        8. Figure 5.8
        9. Figure 5.9
        10. Figure 5.10
        11. Figure 5.11
        12. Figure 5.12
    3. Chapter 6: Fourier Transform
      1. 6.1 Introduction
      2. 6.2 Definition of Fourier Transform
      3. 6.3 Two-Dimensional Fourier Transform
        1. 6.3.1 Fast Fourier Transform using Python
      4. 6.4 Convolution
        1. 6.4.1 Convolution in Fourier Space
      5. 6.5 Filtering in Frequency Domain
        1. 6.5.1 Ideal Lowpass Filter
        2. 6.5.2 Butterworth Lowpass Filter
        3. 6.5.3 Gaussian Lowpass Filter
        4. 6.5.4 Ideal Highpass Filter
        5. 6.5.5 Butterworth Highpass Filter
        6. 6.5.6 Gaussian Highpass Filter
        7. 6.5.7 Bandpass Filter
      6. 6.6 Summary
      7. 6.7 Exercises
        1. Figure 6.1
        2. Figure 6.2
        3. Figure 6.3
        4. Figure 6.4
    4. Chapter 7: Segmentation
      1. 7.1 Introduction
      2. 7.2 Histogram Based Segmentation
        1. 7.2.1 Otsu’s Method
        2. 7.2.2 Renyi Entropy
        3. 7.2.3 Adaptive Thresholding
      3. 7.3 Region Based Segmentation
        1. 7.3.1 Watershed Segmentation
      4. 7.4 Segmentation Algorithm for Various Modalities
        1. 7.4.1 Segmentation of Computed Tomography Image
        2. 7.4.2 Segmentation of MRI Image
        3. 7.4.3 Segmentation of Optical and Electron Microscope Image
      5. 7.5 Summary
      6. 7.6 Exercises
        1. Figure 7.1
        2. Figure 7.2
        3. Figure 7.3
        4. Figure 7.4
        5. Figure 7.5
        6. Figure 7.6
        7. Figure 7.7
    5. Chapter 8: Morphological Operations
      1. 8.1 Introduction
      2. 8.2 History
      3. 8.3 Dilation
      4. 8.4 Erosion
      5. 8.5 Grayscale Dilation and Erosion
      6. 8.6 Opening and Closing
      7. 8.7 Hit-or-Miss
      8. 8.8 Thickening and Thinning
        1. 8.8.1 Skeletonization
      9. 8.9 Summary
      10. 8.10 Exercises
        1. Figure 8.1
        2. Figure 8.2
        3. Figure 8.3
        4. Figure 8.4
        5. Figure 8.5
        6. Figure 8.6
        7. Figure 8.7
        8. Figure 8.8
        9. Figure 8.9
        1. Table 8.1
        2. Table 8.2
    6. Chapter 9: Image Measurements
      1. 9.1 Introduction
      2. 9.2 Labeling
      3. 9.3 Hough Transform
        1. 9.3.1 Hough Line
        2. 9.3.2 Hough Circle
      4. 9.4 Template Matching
      5. 9.5 Summary
      6. 9.6 Exercises
        1. Figure 9.1
        2. Figure 9.2
        3. Figure 9.3
        4. Figure 9.4
  11. Part III: Image Acquisition
    1. Chapter 10: X-Ray and Computed Tomography
      1. 10.1 Introduction
      2. 10.2 History
      3. 10.3 X-Ray Generation
        1. 10.3.1 X-Ray Tube Construction
        2. 10.3.2 X-Ray Generation Process
      4. 10.4 Material Properties
        1. 10.4.1 Attenuation
        2. 10.4.2 Lambert Beer Law for Multiple Materials
      5. 10.5 X-Ray Detection
        1. 10.5.1 Image Intensifier
        2. 10.5.2 Multiple-Field II
        3. 10.5.3 Flat Panel Detector (FPD)
      6. 10.6 X-Ray Imaging Modes
        1. 10.6.1 Fluoroscopy
        2. 10.6.2 Angiography
      7. 10.7 Computed Tomography (CT)
        1. 10.7.1 Reconstruction
        2. 10.7.2 Parallel Beam CT
        3. 10.7.3 Central Slice Theorem
        4. 10.7.4 Fan Beam CT
        5. 10.7.5 Cone Beam CT
        6. 10.7.6 Micro-CT
      8. 10.8 Hounsfield Unit (HU)
      9. 10.9 Artifacts
        1. 10.9.1 Geometric Misalignment Artifacts
        2. 10.9.2 Scatter
        3. 10.9.3 Offset and Gain Correction
        4. 10.9.4 Beam Hardening
        5. 10.9.5 Metal Artifacts
      10. 10.10 Summary
      11. 10.11 Exercises
        1. Figure 10.1
        2. Figure 10.2
        3. Figure 10.3
        4. Figure 10.4
        5. Figure 10.5
        6. Figure 10.6
        7. Figure 10.7
        8. Figure 10.8
        9. Figure 10.9
        10. Figure 10.10
        11. Figure 10.11
        12. Figure 10.12
        13. Figure 10.13
        14. Figure 10.14
        15. Figure 10.15
        16. Figure 10.16
        17. Figure 10.17
        18. Figure 10.18
        19. Figure 10.19
        20. Figure 10.20
        1. Table 10.1
    2. Chapter 11: Magnetic Resonance Imaging
      1. 11.1 Introduction
      2. 11.2 Laws Governing NMR and MRI
        1. 11.2.1 Faraday’s Law
        2. 11.2.2 Larmor Frequency
        3. 11.2.3 Bloch Equation
      3. 11.3 Material Properties
        1. 11.3.1 Gyromagnetic Ratio
        2. 11.3.2 Proton Density
        3. 11.3.3 <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" class="cItalic">T</span><span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" class="cSubscript">1</span> and and <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" class="cItalic">T</span><span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" class="cSubscript">2</span> Relaxation Times Relaxation Times
      4. 11.4 NMR Signal Detection
      5. 11.5 MRI Signal Detection or MRI Imaging
        1. 11.5.1 Slice Selection
        2. 11.5.2 Phase Encoding
        3. 11.5.3 Frequency Encoding
      6. 11.6 MRI Construction
        1. 11.6.1 Main Magnet
        2. 11.6.2 Gradient Magnet
        3. 11.6.3 RF Coils
        4. 11.6.4 K-Space Imaging
      7. 11.7 <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" class="cItalic">T</span><span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" class="cSubscript">1</span>, , <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" class="cItalic">T</span><span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" class="cSubscript">2</span> and Proton Density Image and Proton Density Image
      8. 11.8 MRI Modes or Pulse Sequence
        1. 11.8.1 Spin Echo Imaging
        2. 11.8.2 Inversion Recovery
        3. 11.8.3 Gradient Echo Imaging
      9. 11.9 MRI Artifacts
        1. 11.9.1 Motion Artifact
        2. 11.9.2 Metal Artifact
        3. 11.9.3 Inhomogeneity Artifact
        4. 11.9.4 Partial Volume Artifact
      10. 11.10 Summary
      11. 11.11 Exercises
        1. Figure 11.1
        2. Figure 11.2
        3. Figure 11.3
        4. Figure 11.4
        5. Figure 11.5
        6. Figure 11.6
        7. Figure 11.7
        8. Figure 11.8
        9. Figure 11.9
        10. Figure 11.10
        11. Figure 11.11
        12. Figure 11.12
        13. Figure 11.13
        14. Figure 11.14
        15. Figure 11.15
        16. Figure 11.16
        17. Figure 11.17
        18. Figure 11.18
        19. Figure 11.19
        20. Figure 11.20
        1. Table 11.1
        2. Table 11.2
        3. Table 11.3
        4. Table 11.4
    3. Chapter 12: Light Microscopes
      1. 12.1 Introduction
      2. 12.2 Physical Principles
        1. 12.2.1 Geometric Optics
        2. 12.2.2 Numerical Aperture
        3. 12.2.3 Diffraction Limit
        4. 12.2.4 Objective Lens
        5. 12.2.5 Point Spread Function (PSF)
        6. 12.2.6 Wide-Field Microscopes
      3. 12.3 Construction of a Wide-Field Microscope
      4. 12.4 Epi-Illumination
      5. 12.5 Fluorescence Microscope
        1. 12.5.1 Theory
        2. 12.5.2 Properties of Fluorochromes
        3. 12.5.3 Filters
      6. 12.6 Confocal Microscopes
      7. 12.7 Nipkow Disk Microscopes
      8. 12.8 Confocal or Wide-Field?
      9. 12.9 Summary
      10. 12.10 Exercises
        1. Figure 12.1
        2. Figure 12.2
        3. Figure 12.3
        4. Figure 12.4
        5. Figure 12.5
        6. Figure 12.6
        7. Figure 12.7
        8. Figure 12.8
        1. Table 12.1
        2. Table 12.2
    4. Chapter 13: Electron Microscopes
      1. 13.1 Introduction
      2. 13.2 Physical Principles
        1. 13.2.1 Electron Beam
        2. 13.2.2 Interaction of Electron with Matter
        3. 13.2.3 Interaction of Electrons in TEM
        4. 13.2.4 Interaction of Electrons in SEM
      3. 13.3 Construction of EM
        1. 13.3.1 Electron Gun
        2. 13.3.2 Electromagnetic Lens
        3. 13.3.3 Detectors
      4. 13.4 Specimen Preparations
      5. 13.5 Construction of TEM
      6. 13.6 Construction of SEM
      7. 13.7 Summary
      8. 13.8 Exercises
        1. Figure 13.1
        2. Figure 13.2
        3. Figure 13.3
        4. Figure 13.4
        5. Figure 13.5
        6. Figure 13.6
        7. Figure 13.7
        8. Figure 13.8
        9. Figure 13.9
        10. Figure 13.10
  12. Appendix A: Installing Python Distributions
    1. A.1 Windows
      1. A.1.1 PythonXY
      2. A.1.2 Enthought Python Distribution
      3. A.1.3 Updating or Installing New Modules
    2. A.2 Mac or Linux
      1. A.2.1 Enthought Python Distribution
      2. A.2.2 Installing New Modules
      1. Figure A.1
      2. Figure A.2
      3. Figure A.3
      4. Figure A.4
      5. Figure A.5
      6. Figure A.6
      7. Figure A.7
      8. Figure A.8
      9. Figure A.9
      10. Figure A.10
      11. Figure A.11
      12. Figure A.12
  13. Appendix B: Parallel Programming Using MPI4Py
    1. B.1 Introduction to MPI
    2. B.2 Need for MPI in Python Image Processing
    3. B.3 Introduction to MPI4Py
    4. B.4 Communicator
    5. B.5 Communication
      1. B.5.1 Point-to-Point Communication
      2. B.5.2 Collective Communication
    6. B.6 Calculating the Value of PI
  14. Appendix C: Introduction to ImageJ
    1. C.1 Introduction
    2. C.2 ImageJ Primer
      1. Figure C.1
      2. Figure C.2
      3. Figure C.3
      4. Figure C.4
      5. Figure C.5
  15. Appendix D: MATLAB® and Numpy Functions
    1. D.1 Introduction
  16. Bibliography