Slide 1

Slide 1 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Chaining Operator in Climb Christopher Chedeau LRDE Laboratoire de Recherche et D´ eveloppement d’EPITA July 3, 2011 http://lrde.epita.fr/ 1 / 19 Christopher Chedeau

Slide 2

Slide 2 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion 2 / 19 Christopher Chedeau

Slide 3

Slide 3 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion jQuery Old browsers are full of compatibility issues jQuery1 is a [...] JavaScript Library that simplifies HTML document traversing 1http://jquery.com/ 3 / 19 Christopher Chedeau

Slide 4

Slide 4 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Method Chaining Intuitive API Heavily rely on Method Chaining $(”a”) .addClass(”external”) .attr(”target”, ” blank”) .click(function () { /∗ analytics call ∗/ }) 4 / 19 Christopher Chedeau

Slide 5

Slide 5 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Method Chaining in Javascript function Object() {} Object.prototype = { methodA: function () { // do something return this; }, methodB: function () { // do something return this; } }; var obj = new Object(); obj.methodA().methodB(); It works in any Object Oriented language: C++ Java PHP C# ... 5 / 19 Christopher Chedeau

Slide 6

Slide 6 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Extended Chaining HTML Document Traversing $(”li”) .has(”ul”) .eq(1) .parent() // li: List Item // ul: Unordered List 6 / 19 Christopher Chedeau

Slide 7

Slide 7 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Extended Chaining HTML Document Traversing $(”li”) .has(”ul”) .eq(1) .parent() // li: List Item // ul: Unordered List SQL Query SQL(”select”) .field(”∗”) .table(”users”) .limit(10) 6 / 19 Christopher Chedeau

Slide 8

Slide 8 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Extended Chaining HTML Document Traversing $(”li”) .has(”ul”) .eq(1) .parent() // li: List Item // ul: Unordered List SQL Query SQL(”select”) .field(”∗”) .table(”users”) .limit(10) Asynchronous Tasks $(”
”) .fetch(”navigation.html”) // Asynchronous .addClass(”column”) .appendTo(”#side”) 6 / 19 Christopher Chedeau

Slide 9

Slide 9 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Image processing Image processing chains can be expressed through method chaining Image(”lena.jpg”) .togray() .otsu() .opening(8 connectivity) .save(”lena opening.png”) 7 / 19 Christopher Chedeau

Slide 10

Slide 10 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Straight Common Lisp Implementation Common Lisp methods do not belong to classes (let ((img (load ”lena.jpg”))) (setf img (togray img)) (setf img (otsu img)) (setf img (opening img (8-connectivity))) (save img ”lena opening.png”)) 8 / 19 Christopher Chedeau

Slide 11

Slide 11 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Straight Common Lisp Implementation Common Lisp methods do not belong to classes (let ((img (load ”lena.jpg”))) (setf img (togray img)) (setf img (otsu img)) (setf img (opening img (8-connectivity))) (save img ”lena opening.png”)) The temporary variable is written 8 times 8 / 19 Christopher Chedeau

Slide 12

Slide 12 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Without Temporary Variable (save (opening (otsu (togray (load ”lena.jpg”) ) ) (8−connectivity)) ”lena opening.png”) 9 / 19 Christopher Chedeau

Slide 13

Slide 13 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Without Temporary Variable (save (opening (otsu (togray (load ”lena.jpg”) ) ) (8−connectivity)) ”lena opening.png”) Functions executed last are written first 9 / 19 Christopher Chedeau

Slide 14

Slide 14 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Without Temporary Variable (save (opening (otsu (togray (load ”lena.jpg”) ) ) (8−connectivity)) ”lena opening.png”) Functions executed last are written first Arguments are far away from function name 9 / 19 Christopher Chedeau

Slide 15

Slide 15 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Introduction of Dollar $ Macro Dollar $ Macro ($ (load ”lena.jpg”) (togray) (otsu) (opening 8−connectivity) (save ”lena opening.png”)) Method Chaining Image(”lena.jpg”) .togray() .otsu() .opening(8 connectivity) .save(”lena opening.png”) It takes a sequence of actions 10 / 19 Christopher Chedeau

Slide 16

Slide 16 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Introduction of Dollar $ Macro Dollar $ Macro ($ (load ”lena.jpg”) (togray ) (otsu) (opening 8−connectivity) (save ”lena opening.png”)) Method Chaining Image(”lena.jpg”) .togray() .otsu() .opening(8 connectivity) .save(”lena opening.png”) It takes a sequence of actions The result of each action is passed as first argument on the next Rewritten either with or without temporary variable Can express all the method chaining features 10 / 19 Christopher Chedeau

Slide 17

Slide 17 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Modifiers Not everything fits in the chaining pattern ($ (action) ’(print ”Something”) (action)) 11 / 19 Christopher Chedeau

Slide 18

Slide 18 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Modifiers Not everything fits in the chaining pattern ($ (action) ’(print ”Something”) (action)) We introduce the quote ’ modifier 11 / 19 Christopher Chedeau

Slide 19

Slide 19 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Modifiers Normal behavior (before) (action arg) (after ) 12 / 19 Christopher Chedeau

Slide 20

Slide 20 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Modifiers Normal behavior (before) (action arg) (after ) Quote ’ Modifier (before) $1, $2 ... ’(action arg $1) (after ) 12 / 19 Christopher Chedeau

Slide 21

Slide 21 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Modifiers Normal behavior (before) (action arg) (after ) Quote ’ Modifier (before) $1, $2 ... ’(action arg $1) (after ) Sharp # Modifier (before) $1, $2 ... #(action arg $1) (after ) 12 / 19 Christopher Chedeau

Slide 22

Slide 22 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Grouped Actions Image(”lena.png”) .preprocess() .background() .fill(red) .foreground() .fill(green) . 13 / 19 Christopher Chedeau

Slide 23

Slide 23 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Grouped Actions Image(”lena.png”) .preprocess() .background() .fill(red) .end() .foreground() .fill(green) .end() . [lena] [lena, proc] . [lena, proc, background] [lena, proc, background] [lena, proc] . [lena, proc, foreground] [lena, proc, foreground] [lena, proc] Feels more like a hack Hard to know which methods push to the stack Elements in the stack cannot be garbage collected 13 / 19 Christopher Chedeau

Slide 24

Slide 24 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Introduction of // Macro ($ (load ”lena.png”) (preprocess) (// ((background) (fill red)) ((foreground) (fill green)))) 14 / 19 Christopher Chedeau

Slide 25

Slide 25 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Introduction of // Macro ($ (load ”lena.png”) (preprocess) (// ((background ) (fill red)) ((foreground ) (fill green)))) Explicit dispatch of the value 14 / 19 Christopher Chedeau

Slide 26

Slide 26 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Introduction of // Macro ($ (load ”lena.png”) (preprocess) (// ((background) (fill red)) ((foreground) (fill green))) (combine )) Explicit dispatch of the value Last value of branch can be collected 14 / 19 Christopher Chedeau

Slide 27

Slide 27 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Example Otsu Sauvola 1 Sauvola 5 Otsu - Sauvola 1 Otsu - Sauvola 5 Sauvola 1 - 5 15 / 19 Christopher Chedeau

Slide 28

Slide 28 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Example ($ (load ”lenagray.png”) 16 / 19 Christopher Chedeau

Slide 29

Slide 29 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Example ($ (load ”lenagray.png”) (// 16 / 19 Christopher Chedeau

Slide 30

Slide 30 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Example ($ (load ”lenagray.png”) (// (’(timer−start) 16 / 19 Christopher Chedeau

Slide 31

Slide 31 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Example ($ (load ”lenagray.png”) (// (’(timer−start) (otsu) 16 / 19 Christopher Chedeau

Slide 32

Slide 32 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Example ($ (load ”lenagray.png”) (// (’(timer−start) (otsu) ’(timer−print ”Otsu”) 16 / 19 Christopher Chedeau

Slide 33

Slide 33 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Example ($ (load ”lenagray.png”) (// (’(timer−start) (otsu) ’(timer−print ”Otsu”) (save ”otsu.png”)) ; $1 16 / 19 Christopher Chedeau

Slide 34

Slide 34 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Example ($ (load ”lenagray.png”) (// (’(timer−start) (otsu) ’(timer−print ”Otsu”) (save ”otsu.png”)) ; $1 (’(timer−start) (sauvola (box2d 1)) ’(timer−print ”Sauvola 1”) (save ”sauvola1.png”)) ; $2 16 / 19 Christopher Chedeau

Slide 35

Slide 35 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Example ($ (load ”lenagray.png”) (// (’(timer−start) (otsu) ’(timer−print ”Otsu”) (save ”otsu.png”)) ; $1 (’(timer−start) (sauvola (box2d 1)) ’(timer−print ”Sauvola 1”) (save ”sauvola1.png”)) ; $2 (’(timer−start) (sauvola (box2d 5)) ’(timer−print ”Sauvola 5”) (save ”sauvola5.png”))) ; $3 16 / 19 Christopher Chedeau

Slide 36

Slide 36 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Example ($ (load ”lenagray.png”) (// (’(timer−start) (otsu) ’(timer−print ”Otsu”) (save ”otsu.png”)) ; $1 (’(timer−start) (sauvola (box2d 1)) ’(timer−print ”Sauvola 1”) (save ”sauvola1.png”)) ; $2 (’(timer−start) (sauvola (box2d 5)) ’(timer−print ”Sauvola 5”) (save ”sauvola5.png”))) ; $3 (// (#(diff $1 $2) 16 / 19 Christopher Chedeau

Slide 37

Slide 37 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Example ($ (load ”lenagray.png”) (// (’(timer−start) (otsu) ’(timer−print ”Otsu”) (save ”otsu.png”)) ; $1 (’(timer−start) (sauvola (box2d 1)) ’(timer−print ”Sauvola 1”) (save ”sauvola1.png”)) ; $2 (’(timer−start) (sauvola (box2d 5)) ’(timer−print ”Sauvola 5”) (save ”sauvola5.png”))) ; $3 (// (#(diff $1 $2) (save ”diff1.png”)) 16 / 19 Christopher Chedeau

Slide 38

Slide 38 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Example ($ (load ”lenagray.png”) (// (’(timer−start) (otsu) ’(timer−print ”Otsu”) (save ”otsu.png”)) ; $1 (’(timer−start) (sauvola (box2d 1)) ’(timer−print ”Sauvola 1”) (save ”sauvola1.png”)) ; $2 (’(timer−start) (sauvola (box2d 5)) ’(timer−print ”Sauvola 5”) (save ”sauvola5.png”))) ; $3 (// (#(diff $1 $2) (save ”diff1.png”)) (#(diff $1 $3) (save ”diff2.png”)) (#(diff $2 $3) (save ”diff3.png”)))) 16 / 19 Christopher Chedeau

Slide 39

Slide 39 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Example ($ (load ”lenagray.png”) (// (’(timer−start) (otsu) ’(timer−print ”Otsu”) (save ”otsu.png”)) ; $1 (’(timer−start) (sauvola (box2d 1)) ’(timer−print ”Sauvola 1”) (save ”sauvola1.png”)) ; $2 (’(timer−start) (sauvola (box2d 5)) ’(timer−print ”Sauvola 5”) (save ”sauvola5.png”))) ; $3 (// (#(diff $1 $2) (save ”diff1.png”)) (#(diff $1 $3) (save ”diff2.png”)) (#(diff $2 $3) (save ”diff3.png”)))) ; Otsu: 101ms ; Sauvola 1: 263ms ; Sauvola 5: 3407ms 16 / 19 Christopher Chedeau

Slide 40

Slide 40 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Conclusion Chaining Operator • Ease of use • Entire API has to be rethought Related Work • Implementation of two Component Tree algorithms ([NC04], [BGL+07]) • Overhaul of Value representation • Rationalization of Site Set interface Next Steps • New design patterns from dynamic languages • Explore image processing in the browser 17 / 19 Christopher Chedeau

Slide 41

Slide 41 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Questions ? 18 / 19 Christopher Chedeau

Slide 42

Slide 42 text

Chaining Operator in Climb Introduction Method Chaining jQuery Method Chaining Extended Climb Image Processing Implementation Attempts Dollar macro Extensions Modifiers Parallel Example Conclusion Bibliography Christophe Berger, Thierry G´ eraud, Roland Levillain, Nicolas Widynski, Anthony Baillard, and Emmanuel Bertin, Effective component tree computation with application to pattern recognition in astronomical imaging, Proceedings of the IEEE International Conference on Image Processing (ICIP) (San Antonio, TX, USA), vol. 4, September 2007, pp. IV–41–IV–44. L. Najman and M. Couprie, Quasi-linear algorithm for the component tree, IS&T/SPIE Symposium on Electronic Imaging, In Vision Geometry XII, 2004, pp. 18–22. 19 / 19 Christopher Chedeau