Image Processing in Python

Image Processing in Python

Martin McBride
This is a sample of the book's content.Buy on Leanpub

Table of Contents

Image Processing in Python

  • 1 Foreword
    • 1.1 Who is this book for?
    • 1.2 About the author
    • 1.3 Keep in touch
  • 2 1 Introduction to vector graphics
    • 2.1 1.1 Pixel images
    • 2.2 1.2 Size and resolution
    • 2.3 1.3 Resizing pixel images
    • 2.4 1.4 Drawing on pixel images
    • 2.5 1.5 Vector graphics
    • 2.6 1.6 Rendering
    • 2.7 1.7 Typical uses
    • 2.8 1.8 Benefits
    • 2.9 1.9 Disadvantages
    • 2.9.1 1.9.1 Complexity of conversion
    • 2.9.2 1.9.2 Pixel image elements
    • 2.9.3 1.9.3 Fonts
    • 2.9.4 1.9.4 Editability
    • 2.10 1.10 Common vector formats
  • 3 2 About Pycairo
    • 3.1 2.1 Cairo
    • 3.2 2.2 Capabilities
    • 3.3 2.3 Version
    • 3.4 2.4 Installing Pycairo
    • 3.4.1 2.4.1 Windows
    • 3.4.2 2.4.2 Linux
    • 3.4.3 2.4.3 Mac
    • 3.5 2.5 Checking Pycairo version
  • 4 3 Basic drawing operations
    • 4.1 3.1 Creating an image with Pycairo
    • 4.1.1 3.1.1 Setting up Pycairo
    • 4.1.2 3.1.2 Drawing the image
    • 4.1.3 3.1.3 Saving the PNG file
    • 4.2 3.2 Coordinate system
    • 4.3 3.3 Rectangles
    • 4.4 3.4 Fill and stroke
    • 4.5 3.5 Lines
    • 4.6 3.6 Polygons
    • 4.7 3.7 Open and closed shapes
    • 4.8 3.8 Arcs
    • 4.9 3.9 Circles
    • 4.10 3.10 Bezier curves
    • 4.11 3.11 Line styles
    • 4.11.1 3.11.1 Line caps
    • 4.11.2 3.11.2 Line joins
    • 4.11.3 3.11.3 Mitre limit
    • 4.11.4 3.11.4 Dashed lines
  • 5 4 Paths and complex shapes
    • 5.1 4.1 Paths
    • 5.2 4.2 Sub-paths
    • 5.2.1 4.2.1 Creating sub-paths
    • 5.3 4.3 Lines
    • 5.3.1 4.3.1 Drawing a line of given length and angle
    • 5.3.2 4.3.2 Relative drawing functions
    • 5.4 4.4 Polygons
    • 5.4.1 4.4.1 A simple arrow
    • 5.5 4.5 Arcs
    • 5.5.1 4.5.1 Arc angle rules
    • 5.5.2 4.5.2 Arcs and the current point
    • 5.5.3 4.5.3 Sectors and segments
    • 5.5.4 4.5.4 Roundrect
    • 5.5.5 4.5.5 arc-negative
    • 5.6 4.6 Bezier curves
    • 5.6.1 4.6.1 Common forms
    • 5.6.2 4.6.2 Splines
    • 5.6.3 4.6.3 Smooth curves
    • 5.7 4.7 Function curves
    • 5.8 4.8 Rectangle
  • 6 5 Computer colour
    • 6.1 5.1 RGB colour
    • 6.1.1 5.1.1 Why RGB?
    • 6.2 5.2 Pycairo RGB colours
    • 6.2.1 5.2.1 Primary colours
    • 6.2.2 5.2.2 Secondary colours
    • 6.2.3 5.2.3 All colours
    • 6.3 5.3 CSS named colours
    • 6.4 5.4 Transparency
    • 6.5 5.5 Transparency colour calculation
    • 6.6 5.6 Transparent images
    • 6.7 5.7 Greyscale images
    • 6.8 5.8 Pixel colours
    • 6.8.1 5.8.1 Other image formats
  • 7 6 Transforms and state
    • 7.1 6.1 User space and device space
    • 7.2 6.2 Translation
    • 7.3 6.3 Scaling
    • 7.3.1 6.3.1 Scaling down
    • 7.3.2 6.3.2 Unequal scaling
    • 7.4 6.4 Rotation
    • 7.5 6.5 Save and restore
    • 7.5.1 6.5.1 Save and restore are stacked
    • 7.6 6.6 Rotating about a point
    • 7.7 6.7 Placing an ellipse
    • 7.8 6.8 Correcting the effects of unequal scaling
    • 7.9 6.9 Flipping
    • 7.10 6.10 Current transform matrix
  • 8 7 Working with text
    • 8.1 7.1 Text is just shapes
    • 8.2 7.2 How Pycairo handles text
    • 8.3 7.3 Fonts
    • 8.4 7.4 Font size
    • 8.4.1 7.4.1 Point size
    • 8.4.2 7.4.2 Em squares
    • 8.5 7.5 Font style
    • 8.6 7.6 Text extents
    • 8.7 7.7 Text extent examples
    • 8.8 7.8 Text alignment
  • 9 8 Gradients and image fills
    • 9.1 8.1 Patterns
    • 9.2 8.2 SolidPattern
    • 9.2.1 8.2.1 SolidPattern vs set_source_rgb
    • 9.2.2 8.2.2 Creating a transparent SolidPattern
    • 9.3 8.3 Linear gradient
    • 9.3.1 8.3.1 Transparent stops
    • 9.4 8.4 Linear gradients at different angles
    • 9.5 8.5 Adding more stops
    • 9.5.1 8.5.1 Flat colours
    • 9.5.2 8.5.2 Step changes
    • 9.6 8.6 Extend options
    • 9.7 8.7 Filling a stroke with a gradient
    • 9.8 8.8 Filling text with a gradient
    • 9.9 8.9 Radial gradients
    • 9.10 8.10 Radial gradient with inner circle
    • 9.11 8.11 Radial extend options
    • 9.12 8.12 Loading an image into Pycairo
    • 9.13 8.13 Using SurfacePattern with an image
    • 9.13.1 8.13.1 Transforming the image
    • 9.13.2 8.13.2 Tiling the image
    • 9.14 8.14 SurfacePattern extend options
    • 9.15 8.15 Using SurfacePattern with vectors
  • 10 9 Clipping, masking and compositing
    • 10.1 9.1 Clipping
    • 10.1.1 9.1.1 Using clipping to create complex shapes
    • 10.2 9.2 Calling clip multiple times
    • 10.3 9.3 Resetting the clip region
    • 10.4 9.4 Clipping functions
    • 10.5 9.5 Masking
    • 10.6 9.6 Using an image as a mask
    • 10.7 9.7 Compositing
    • 10.7.1 9.7.1 Compositing terms
    • 10.7.2 9.7.2 Setting the operator
    • 10.8 9.8 OVER operator
    • 10.9 9.9 Changing the drawing order
    • 10.10 9.10 Masking operations
    • 10.10.1 9.10.1 Other masking modes
    • 10.11 9.11 Artistic colour adjustments
    • 10.12 9.12 Specific colour changes
  • 11 10 Surfaces and output formats
    • 11.1 10.1 Output formats
    • 11.2 10.2 ImageSurface
    • 11.2.1 10.2.1 Formats
    • 11.2.2 10.2.2 Loading images
    • 11.2.3 10.2.3 Accessing the image data
    • 11.3 10.3 SVGSurface
    • 11.3.1 10.3.1 Other SVGSurface methods
    • 11.4 10.4 PDFSurface
    • 11.4.1 10.4.1 Multipage PDFs
    • 11.4.2 10.4.2 Other PDFSurface methods
    • 11.5 10.5 PSSurface
    • 11.6 10.6 RecordingSurface
    • 11.7 10.7 ScriptSurface
    • 11.8 10.8 TeeSurface
    • 11.9 10.9 GUI surfaces
  • 12 11 Integration with other libraries
    • 12.1 11.1 How Pycairo stores image data
    • 12.1.1 11.1.1 Data format
    • 12.1.2 11.1.2 RGB24 data
    • 12.1.3 11.1.3 Accessing data as bytes
    • 12.1.4 11.1.4 ARGB32 data
    • 12.1.5 11.1.5 Other formats
    • 12.2 11.2 PIL (Pillow) integration
    • 12.2.1 11.2.1 Reading a JPEG file
    • 12.2.2 11.2.2 Writing a JPEG file
    • 12.3 11.3 Numpy integration
    • 12.3.1 11.3.1 Creating a numpy array from a surface
    • 12.3.2 11.3.2 Creating a surface from a numpy array
  • 13 12 Reference
    • 13.1 12.1 Radians
    • 13.1.1 12.1.1 What are radians
    • 13.1.2 12.1.2 Conversion
    • 13.1.3 12.1.3 Key angles
Image Processing in Python/Overview

Image Processing in Python

Course overview

How to automate image processing in Python usnig the Pillow library.

13 chapters
Begin reading
Download
The Book

Image Processing in Python13 chapters

Begin ›
  1. 1 Foreword

  2. 2 1 Introduction to vector graphics

  3. 3 2 About Pycairo

  4. 4 3 Basic drawing operations

  5. 5 4 Paths and complex shapes

  6. 6 5 Computer colour

  7. 7 6 Transforms and state

  8. 8 7 Working with text

  9. 9 8 Gradients and image fills

  10. 10 9 Clipping, masking and compositing

  11. 11 10 Surfaces and output formats

  12. 12 11 Integration with other libraries

  13. 13 12 Reference