Skip to topic | Skip to bottom
Home
Olena
Olena.Swilenar1.3 - 29 Mar 2010 - 15:28 - RolandLevillaintopic end

Start of topic | Skip to actions

Swilena

Swilena the a SWIG-based scripting interface of the Olena platform. It currently features a Python interface to the Milena C++ library. Support for Ruby (as in Olena 0.11) is also planned.

Swilena/Python

Swilena/Python gives access to a subset of Milena through the Python programming language. Currently, only a few data structures and morphological algorithms are available; more wrappers will be released later.

The code written using Swilena/Python looks like a simplified version of the Milena equivalent C++ code (no type annotations, no template constructs, etc.). For instance, the following script performs a watershed-based segmentation.

import data
from swilena import *

image = image2d_int_u8

# Input.
ima = image.load("lena.pgm")

# Gradient.
gradient = image.gradient(ima, win_c4p())

# Area closing of the gradient.
closed_gradient = image.closing_area(ima, c4(), 50)

# Watershed transform.
nbasins = int_u8()
ws = image.meyer_wst (closed_gradient, c4(), nbasins)

# Output.
print nbasins
image.save(ws, "segm.pgm")

As most of the work is accomplished by (wrapped) C++ compiled code, the execution speed is comparable with pure C++ code.

Swilena Python Shell

Swilena is also usable through the Swilena Python Shell (sps). sps is an interactive loop executing Swilena/Python commands, based on the Python interpreter.

% sps
The Swilena Python Shell (sps).
Type "help", "copyright", "credits" or "license" for more information on Python
Type "example" for a short example.
Type "quit()" or ^D (Ctrl-D) to quit.
>>> example
The following example creates a 2-d image of integers with 3 rows and
3 columns, then fills its cells with the value `42' and prints it:

  ima = image2d_int.image2d_int(3, 3)
  image2d_int.fill(ima, 42)
  image2d_int.println(ima)

You can try it by copying and pasting each line on the following prompt.

>>> ima = image2d_int.image2d_int(3, 3)
>>> image2d_int.fill(ima, 42)
>>> image2d_int.println(ima)
42 42 42 
42 42 42 
42 42 42 

>>> exit()
%

Installing Swilena

If you are installing the Olena 1.0 distribution (or greater), you can ask the build system to compile and install Swilena by passing the flags --with-swig and --enable-swilena to configure before invoking make:

   ./configure --with-swig --enable-swilena
   make
   sudo make install

to top

You are here: Olena > Components > Swilena

to top

Copyright © 1999-2010 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback