olena & milena in a few words

45
Outline Olena & Milena in a Few Words EPITA Research and Development Laboratory (LRDE) May 2009 Olena & Milena in a Few Words EPITA-LRDE 2009 1 / 44

Upload: others

Post on 16-Oct-2021

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Olena & Milena in a Few Words

Outline

Olena & Milena in a Few Words

EPITA Research and Development Laboratory (LRDE)

May 2009

Olena & Milena in a Few Words EPITA-LRDE 2009 1 / 44

Page 2: Olena & Milena in a Few Words

Outline

Outline

1 About MilenaPresentationGenericityComparison

2 Current StatusLibraryDynamic Interface

Olena & Milena in a Few Words EPITA-LRDE 2009 2 / 44

Page 3: Olena & Milena in a Few Words

Outline

Outline

1 About MilenaPresentationGenericityComparison

2 Current StatusLibraryDynamic Interface

Olena & Milena in a Few Words EPITA-LRDE 2009 2 / 44

Page 4: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Outline

1 About MilenaPresentationGenericityComparison

2 Current StatusLibraryDynamic Interface

Olena & Milena in a Few Words EPITA-LRDE 2009 3 / 44

Page 5: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Project 1/2

Naming

Olena : image processinga platform (also project name)

Milena : image processing library = part of Olenaa

IP, image processing for short

Goals

1 Focus on the library part (Milena)

2 Add a scripting layer (interpreted environment).

3 Add extra tools(visual env., interface with The GIMP, Octave, etc.)

Olena & Milena in a Few Words EPITA-LRDE 2009 4 / 44

Page 6: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Project 2/2

Rational

Features: platform features come from the library

Limitations: library limitations are viral:they affect the platform

A Couple of Key Ideas

Operators: too many things in IP (algorithms, methods...)

Objectives: instead, to ease programming IP

Olena & Milena in a Few Words EPITA-LRDE 2009 5 / 44

Page 7: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

What’s In a Library

Algorithms:procedures dedicated to image processing and pattern recognition

Data types for pixel values:gray level types with different quantizations, several floating types, color types

Data structures:for instance, many ways to define images and sets of points

A lot of auxiliary tools:they help to easily write readable algorithms and methods in a concise way!

Olena & Milena in a Few Words EPITA-LRDE 2009 6 / 44

Page 8: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Objectives of Milena as a Feature List

Genericity not limited to very few types of values and images

Simplicity as easy to use as a C or Java library

Efficiency ready to intensive computation (large data / sets of data)

Composability coherency of tools ensure software building from blocks

Safety errors are pointed out at compile-time, otherwise at run-time

Reusability software blocks are provided for general purpose

Getting at the same time all those features is very challenging.

Olena & Milena in a Few Words EPITA-LRDE 2009 7 / 44

Page 9: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

History

Version Features Misfeatures2000-01 0.1 genericity w.r.t. values rectangular 2D images

only!2001-04 0.10 genericity w.r.t. both

structures and valueslimitations...(Cf. next slides)

2004-07 X prototype too sophisticated design,very slow compilation : −(

yet many solutions usedin v1.0 : −)

2007 0.11 just an update of 0.10 same as 0.102007-09 1.0 full genericity ...

Olena & Milena in a Few Words EPITA-LRDE 2009 8 / 44

Page 10: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Outline

1 About MilenaPresentationGenericityComparison

2 Current StatusLibraryDynamic Interface

Olena & Milena in a Few Words EPITA-LRDE 2009 9 / 44

Page 11: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

The Most Dummy Example

Filling an image ima with the value v:

// Java or C -like code

void fill(image∗ ima, unsigned char v){

for (int i = 0; i < ima−>nrows; ++i)for (int j = 0; j < ima−>ncols; ++j)

ima−>data[i][j] = v;}

Note that we really have here an example very representative of an algorithm and ofmany pieces of existing code.

Olena & Milena in a Few Words EPITA-LRDE 2009 10 / 44

Page 12: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Some Observations 1/2

Kleenex

There are a lot of implicit assumptions about the input:

• The input image has to be 2D;

• its definition domain has to be a rectangle;

• this rectangle shall start at (0,0);

• data cannot be of a different type than “unsigned char”;

• last, data need to be stored as a 2D array in RAM.

This is a kleenex code:“code once, run on one image type”

For instance this routine cannot work on a region of interest of a 2D image having floating values.

Olena & Milena in a Few Words EPITA-LRDE 2009 11 / 44

Page 13: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Some Observations 2/2

Obfuscation

Working on a particular type of image leads to the presence ofimplementation details.

This is a dirty kleenex code:

“implementation details obfuscate the actual algorithm”

Furthermore, it is:• verbose

• error-prone

• hard to maintain.

Olena & Milena in a Few Words EPITA-LRDE 2009 12 / 44

Page 14: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Definition

A Generic Algorithm

A generic algorithm is written once (without duplicates)and

works on different kind of input

Olena & Milena in a Few Words EPITA-LRDE 2009 13 / 44

Page 15: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Generic algorithm translation

Algorithm:

Procedure fillima : an image (type: any type I)v : a value (type: value type of I)

beginfor all p in ima domain

ima(p)← vend

// Milena code:

template <typename I>void fill( I& ima,

mln value(I) v ){

mln piter(I) p(ima.domain());for all(p)

ima(p) = v;}

Olena & Milena in a Few Words EPITA-LRDE 2009 14 / 44

Page 16: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Example

The basic (common) run:

using literal::green;data::fill(lena, literal::green);

before: after:

Olena & Milena in a Few Words EPITA-LRDE 2009 15 / 44

Page 17: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Example cont’d

Filling only a region of interest (a set of points):

mln VAR(roi, lena | make::box2d(5,5, 10,10));data::fill(roi, literal::green);

before: after:

Olena & Milena in a Few Words EPITA-LRDE 2009 16 / 44

Page 18: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Example cont’d

Filling only points verifying a predicate:

mln VAR(lena c, lena | fun::p2b::chess());data::fill(lena c, literal::green);

before: after:

Olena & Milena in a Few Words EPITA-LRDE 2009 17 / 44

Page 19: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Example cont’d

Likewise, the predicate being a mask image:

mln VAR(lena m, lena | pw::value(mask));data::fill(lena m, literal::green);

before: mask: after:

Olena & Milena in a Few Words EPITA-LRDE 2009 18 / 44

Page 20: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Example cont’d

Likewise, relying on an image of labels:

mln VAR(lena 3, lena | (pw::value(label) == 3));data::fill(lena 3, literal::green);

before: label: after:

Olena & Milena in a Few Words EPITA-LRDE 2009 19 / 44

Page 21: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Example cont’d

Filling only a component:

mln VAR(lena g, fun::access::green << lena);data::fill(lena g, literal::green);

before: after:

Olena & Milena in a Few Words EPITA-LRDE 2009 20 / 44

Page 22: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Example cont’d

Mixing several “image views”:

mln VAR(lena g3, lena g | pw::value(label) == 3);data::fill(lena g3, literal::green);

before: label: after:

Olena & Milena in a Few Words EPITA-LRDE 2009 21 / 44

Page 23: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Some Remarks 1/2

Replace the 2D image by:

a signala volumea grapha complexetc.

and it works as is...

Olena & Milena in a Few Words EPITA-LRDE 2009 22 / 44

Page 24: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Some Remarks 2/2

Genericity applies on:

values of imagesstructures of imagesmodifiers of images (Cf. previous slides)neighborhoodsfunctionsetc.

Olena & Milena in a Few Words EPITA-LRDE 2009 23 / 44

Page 25: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Past Limitations

From 0.11 to 1.0Limitations of version 0.11 did not allow to have the previousexamples work.

Olena & Milena in a Few Words EPITA-LRDE 2009 24 / 44

Page 26: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Outline

1 About MilenaPresentationGenericityComparison

2 Current StatusLibraryDynamic Interface

Olena & Milena in a Few Words EPITA-LRDE 2009 25 / 44

Page 27: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Four Kinds of Users

Assemblers: just compose components (algorithms) tosolve a problem

Designers: write new algorithms

Providers: write new data types

Architects: focus on the library core

Required skills go increasingly within this list.

Olena & Milena in a Few Words EPITA-LRDE 2009 26 / 44

Page 28: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Code Comparison

Image practionners write algorithms...

...so have a look at the same code.

Olena & Milena in a Few Words EPITA-LRDE 2009 27 / 44

Page 29: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Tivoli

Context: TSI, ENST

Author: theo

Year: 1995

Language: C

Olena & Milena in a Few Words EPITA-LRDE 2009 28 / 44

Page 30: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Pink

Context: ESIEE

Author: Michel Couprie

Year: 1997

Language: C

Olena & Milena in a Few Words EPITA-LRDE 2009 29 / 44

Page 31: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

OpenCV

Context/Author: Intel

Year: 2000

Language: C++

Olena & Milena in a Few Words EPITA-LRDE 2009 30 / 44

Page 32: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

ITK 1/2

Olena & Milena in a Few Words EPITA-LRDE 2009 31 / 44

Page 33: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

ITK 2/2

Context: ITK

Author: Insight Software

Consortium

Year: 2006

Language: C++

Olena & Milena in a Few Words EPITA-LRDE 2009 32 / 44

Page 34: Olena & Milena in a Few Words

About MilenaCurrent Status

PresentationGenericityComparison

Milena

Context: LRDE

Author: theo

Year: 2007

Language: C++

Olena & Milena in a Few Words EPITA-LRDE 2009 33 / 44

Page 35: Olena & Milena in a Few Words

About MilenaCurrent Status

LibraryDynamic Interface

Outline

1 About MilenaPresentationGenericityComparison

2 Current StatusLibraryDynamic Interface

Olena & Milena in a Few Words EPITA-LRDE 2009 34 / 44

Page 36: Olena & Milena in a Few Words

About MilenaCurrent Status

LibraryDynamic Interface

Some Facts

About versions:1.0β released in December 20081.0 is due to June 10th, 2009

Current version is fully functional and used:

in large projects:Melimage (funded by INCA)SCRIBO (funded by System@tic)

in students projectsabout a dozen per years

Olena & Milena in a Few Words EPITA-LRDE 2009 35 / 44

Page 37: Olena & Milena in a Few Words

About MilenaCurrent Status

LibraryDynamic Interface

Documentation

We have

a white paper

a tutorial

a reference guidehttp://www.lrde.epita.fr/dload/doc/milena-1.0/

Olena & Milena in a Few Words EPITA-LRDE 2009 36 / 44

Page 38: Olena & Milena in a Few Words

About MilenaCurrent Status

LibraryDynamic Interface

Entering Milena

Easy? Quick?

From our experiments:

two days are enough to take Milena in hand

the learning curve is great.

Olena & Milena in a Few Words EPITA-LRDE 2009 37 / 44

Page 39: Olena & Milena in a Few Words

About MilenaCurrent Status

LibraryDynamic Interface

Outline

1 About MilenaPresentationGenericityComparison

2 Current StatusLibraryDynamic Interface

Olena & Milena in a Few Words EPITA-LRDE 2009 38 / 44

Page 40: Olena & Milena in a Few Words

About MilenaCurrent Status

LibraryDynamic Interface

Static-Dynamic Bridge

Need for a Bridge

On one hand:Milena = efficient C++ generic, thus static, code.

On the other hand:a dynamic environment (script, interpreter, GUI).

⇒ A bridge between both worlds is required.

Olena & Milena in a Few Words EPITA-LRDE 2009 39 / 44

Page 41: Olena & Milena in a Few Words

About MilenaCurrent Status

LibraryDynamic Interface

Our Solution: Swilena 1/2

Tools

Swilena is the bridge provided in Olena to access Milena fromanother language.

SPS (Swilena Python Shell) is a command line interpreter.

History:architecture sketched in 2000 (GCSE Workshop)started in 2002functional until version 0.11up again in Summer 2008

Olena & Milena in a Few Words EPITA-LRDE 2009 40 / 44

Page 42: Olena & Milena in a Few Words

About MilenaCurrent Status

LibraryDynamic Interface

Our Solution: Swilena 2/2

The how-to

it works on closed world (a context)

for a given type, you get access to a subset of the library(for instance, image2d<int_u8>

About writing this bridge

the starting cost is very quickly amortized

it can be done in a very modularized way

Olena & Milena in a Few Words EPITA-LRDE 2009 41 / 44

Page 43: Olena & Milena in a Few Words

About MilenaCurrent Status

LibraryDynamic Interface

Sample Code 1/3

Morphological glue:

%module morpho

%include "concrete.ixx"

/∗ dilation ∗/%{#include "mln/morpho/dilation.hh"%}%include "mln/morpho/dilation.hh"%define instantiate dilation(Name, I, W)

%template() mln::trait::concrete< I >;%template(Name) mln::morpho::dilation< I, W >;

%enddef

/∗ morphology ∗/%define instantiate morpho(I, W, N)

instantiate dilation(dilation, I, W)instantiate erosion(erosion, I, W)/∗ ... ∗/

%enddef

Olena & Milena in a Few Words EPITA-LRDE 2009 42 / 44

Page 44: Olena & Milena in a Few Words

About MilenaCurrent Status

LibraryDynamic Interface

Sample Code 2/3

A precise world:

%module image2d int

%include "intp.ixx"

%include "image2d.ixx"instantiate image2d(image2d int, int)

%include "window2d.ixx"%include "neighb2d.ixx"

%include "morpho.ixx"instantiate morpho(mln::image2d<int>, mln::window2d, mln::neighb2d)

Olena & Milena in a Few Words EPITA-LRDE 2009 43 / 44

Page 45: Olena & Milena in a Few Words

About MilenaCurrent Status

LibraryDynamic Interface

Sample Code 3/3

Sample use:

from swilena import ∗

# Module alias.image = image2d int u8

# Load.f = image.io pgm load("lena.pgm")

# Gradient.g = image.morpho elementary gradient(f, c4())

# Area closing of the gradient.h = image.morpho closing area(g, c4(), 50)

# Watershed transform.n basins = int u8();w = image.morpho watershed flooding(h, c4(), nbasins)print n basins

# Save.image.io pgm save(w, "w.pgm")

Olena & Milena in a Few Words EPITA-LRDE 2009 44 / 44