Chaining Operator in Climb Method Chaining jQuery Method Chaining - - PowerPoint PPT Presentation

chaining operator in climb
SMART_READER_LITE
LIVE PREVIEW

Chaining Operator in Climb Method Chaining jQuery Method Chaining - - PowerPoint PPT Presentation

Chaining Operator in Climb Introduction Chaining Operator in Climb Method Chaining jQuery Method Chaining Extended Climb Christopher Chedeau Image Processing Implementation Attempts Dollar macro LRDE Extensions Laboratoire de


slide-1
SLIDE 1

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

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

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

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

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();

  • bj.methodA().methodB();

It works in any Object Oriented language:

◮ C++ ◮ Java ◮ PHP ◮ C# ◮ ... 5 / 19 Christopher Chedeau

slide-6
SLIDE 6

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

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

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

$(”<div/>”) .fetch(”navigation.html”) // Asynchronous .addClass(”column”) .appendTo(”#side”)

6 / 19 Christopher Chedeau

slide-9
SLIDE 9

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

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

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

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

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

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

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

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

  • n the next

◮ Rewritten either with or without temporary variable ◮ Can express all the method chaining features 10 / 19 Christopher Chedeau

slide-17
SLIDE 17

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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