context oriented image processing
play

Context-Oriented Image Processing Didier Verna Introduction - PowerPoint PPT Presentation

Context- Oriented Image Processing Context-Oriented Image Processing Didier Verna Introduction Reconciling Genericity and Performance through Contexts Genericity Contexts Optimization Didier Verna didier@lrde.epita.fr


  1. Context- Oriented Image Processing Context-Oriented Image Processing Didier Verna Introduction Reconciling Genericity and Performance through Contexts Genericity Contexts Optimization Didier Verna didier@lrde.epita.fr http://www.lrde.epita.fr/˜didier http://www.facebook.com/didierverna @didierverna COP 2015 – Sunday, July 5 1/21

  2. Table of contents Context- Oriented Image Introduction 1 Processing Didier Verna Generic Image Processing 2 Introduction Genericity Contextual Image Processing Contexts 3 Optimization Contextual Optimizations 4 2/21

  3. Introduction The Common Lisp Image Manipulation Bundle Context- Oriented Climb Image Processing Highly generic image processing library Didier Verna DSL / GML for complex image processing chains Introduction Inspired by Milena (C++ / templates) Genericity Contexts Genericity drawbacks Optimization Performance degradation Code cluttering / OO Design breakage Agenda Public: reconciling genericity and performance Hidden (not so) : explore the benefits of a multi-paradigm dynamic language 4/21

  4. Generic Image Processing Abstracting images, neighborhoods, pixels etc Context- Oriented The duality of “pixels” Image Processing A value ? A location on a 2D grid ? Didier Verna Introduction 2 key concepts: sites and values Genericity Image Definition Image = f ( site ) → value Graph-Based Images Processing Chains Site sets: (iterators) full images, neighborhoods etc Contexts Values: (regular OO design) RGB, RGBA, bits, ints, Optimization floats, 32, 64 etc 6/21

  5. Generic Image Processing Abstracting images, neighborhoods, pixels etc Context- Oriented Generic Dilation Algorithm Image Processing (defun dilation Didier Verna (image &aux (result (copy image))) Introduction (do-sites (site (domain image)) Genericity (let ((max no-value)) Image Definition Graph-Based Images (do-sites (neighbor (neighbors site)) Processing Chains (setq max (max max Contexts (iref image neighbor)))) Optimization (setf (iref result site) max))) result) 7/21

  6. Graph-Based Image Example Segmentation Context- Oriented Image Processing Didier Verna Introduction Genericity Image Definition Graph-Based Images Processing Chains Contexts Optimization 8/21

  7. Dilation Algorithm Examples On regular 2D and graph-based images Context- Oriented Image Original Result Processing Didier Verna Introduction Genericity Image Definition Graph-Based Images Processing Chains Contexts Optimization 9/21

  8. The GUI / GML Climb also provides a textual DSL Context- Oriented Image Processing Didier Verna Introduction Genericity Image Definition Graph-Based Images Processing Chains Contexts Optimization 10/21

  9. A GML Example Contour Detection Algorithm Context- Oriented Image Processing Didier Verna Introduction Genericity Image Definition Graph-Based Images Processing Chains Contexts Optimization 11/21

  10. Contextual Image Processing Rationale Context- Oriented Generic Image Processing Drawbacks Image Processing Image specificities not taken into account Didier Verna Runtime cost for abstraction layers (in general) Introduction Even worse for image processing Genericity Contexts Optimization 13/21

  11. Image Specificities To be taken into account Context- Oriented Reasonably easy Image Processing Image formats, storage types, pixel values etc Didier Verna Still, code cluttering (class proliferation) Introduction Genericity Cross-cutting Contexts Optimization Image properties Orthogonal to regular specificities Example: speed property for site access ◮ slow ◮ fast ( O ( 1 ) ) ◮ fastest ( O ( 1 ) + pointer arithmetic) ◮ Depends on both the image type and the site-set type 14/21

  12. Introducing Contexts “Cross-cutting” should ring a bell! Context- Oriented Layering image properties/specificities Image Processing Layered generic functions: algorithm specialization Didier Verna Layered classes: structural specialization Introduction Genericity Contexts Optimization 15/21

  13. Behavioral Optimization Example Static Typing Context- Oriented Image Processing Didier Verna Introduction Genericity Contexts Optimization Behavioral Dynamic types ⇛ polymorphic operations (slow) Subclassing ⇒ class proliferation (bad) 17/21

  14. Layering value classes Layered static types Context- Oriented Layered RGB class Image Processing (deftype uint8-color () ’(unsigned-byte 8)) Didier Verna (deflayer uint8-color-value) Introduction Genericity (define-layered-class rgb Contexts :in-layer uint8-color-value (value) Optimization ((red :type uint8-color) Behavioral (green :type uint8-color) (blue :type uint8-color))) 18/21

  15. Layering functions Layered static types Context- Oriented Optimized algorithms Image Processing (define-layered-method make-grayscale Didier Verna :in-layer uint8-color-value ((rgb rgb)) Introduction (declare (optimize (speed 3) (safety 0))) Genericity (make-instance ’grayscale Contexts :intensity Optimization (the uint8-color Behavioral (round (the float (+ (the float (* (red rgb) 0.299)) (the float (* (green rgb) 0.587)) (the float (* (blue rgb) 0.114)))))))) 19/21

Recommend


More recommend