$extrastylesheet
Routine name | Description |
duplicate() | creates a deep copy of an object. Any shared data is duplicated. |
data::fill() | fill an object with a value. |
data::paste() | paste object data to another object. |
labeling::blobs() | find and label the different components of an image. |
logical::not_() logical::not_inplace() | Point-wise "logical not" |
*::compute() | compute an accumulator on specific elements. |
Memory has been allocated so data can be stored but site values have not been initialized yet. So we fill imga with the value ’a’:
The fill() algorithm is located in the sub-namespace "mln::data" since this algorithm deals with the site values.
The full name of this routine is mln::data::fill(). To access to a particular algorithm, the proper file shall be included. The file names of algorithms strictly map their C++ name; so mln::data::fill is defined in the file mln/data/fill.hh.
Most algorithms in Olena are constructed following the classical scheme: "output algo(input)", where the input image is only read. However some few algorithms take an input image in order to modify it. To enforce this particular feature, the user shall explicitly state that the image is provided so that its data is modified "read/write". The algorithm call shall be data::fill(ima.rw(), val). When forgetting the rw() call, it does not compile.
With this simple example we can see that images defined on different domains (or set of sites) can interoperate. The set of sites of an image is defined and can be accessed and printed. The following code:
Gives:
The notion of site sets plays an important role in Olena. Many tests are performed at run-time to ensure that the program is correct.
For instance, the algorithm data::paste() tests that the set of sites of imgb (whose values are to be pasted) is a subset of the destination image.
labeling::blobs() is used to label an image. It returns a new image with the component id as value for each site. The background has 0 as id therefore the component ids start from 1.
Consider the following image:
Output:
Then label this image thanks to labeling::blobs():
Output:
Note that this routine returns the number of components in its third parameter. This parameter must be of the same type as the returned image value.
Header | mln/logical/not.hh |
Full namespace | mln::logical |
Routine(s) | not_(), not_inplace() |
This small routine only works on binary images. It performs a point-wise "logical not" and therefore "negates" the image. There are two versions of that algorithm: a version which returns a new image and another which works in place. Example:
Make a binary image:
Return the result in a new image:
![]() |
![]() |
ima (left) and imaneg (right) after having called logical::not_(). |
Or, work in place:
There are several flavour of the compute routine, depending on what the kind of elements it computes.
labeling::compute() | compute an accumulator for each component in a labeled image. |
data::compute() | compute an accumulator on the values of an image. |
Name | Description |
bbox | Bounding boxes |
count_adjacent_vertices | Count adjacent vertices |
count | Count the number of sites |
height | |
volume |
Name | Description |
histo | Histogram |
max | Max value |
max_h | Max value (Hexa) |
mean | Mean value |
median_alt | Median |
median_h | Median (Hexa) |
min | Min value |
min_h | Min value (Hexa) |
min_max | Min and Max value |
rank_bool | |
rank | |
rank_high_quant | |
sum | Sum the values |
Name | Description |
pair | Pair of accumulators |
tuple | n-uplets of accumulators |
Each accumulator can be used in *::compute(). It exists two versions of each accumulator.
Note that when an accumulator is passed to *::compute(), it must be instanciated.You cannot write:
Instead, you must write:In this example we will try to retrieve the bounding box of each component in an image.
Consider the following image:
Then label this image thanks to labeling::blobs():
Then, use labeling::compute() with the bbox accumulator:
labeling::compute() holds an accumulator for each component, which means it returns an array of accumulator results. In this case, it returns an array of box2d.
Important note: since labeling::blobs() labels the component from 1 and set the background to 0, we will want to iterate from 1 to nlabels included.
In order to make the code cleaner, small routines are available for the most used accumulators.
Currently there are the following routines:
Name | Description |
nsites | Return the number of sites of an image or a site set. |
mean | Return the mean of the values of an image. |
min_max | Return the min and max values of the values of an image. |
sum | Return the sum of the values of an image. |
These routines can be found in mln/geom and in mln/estim. For example, with geom::nsites() simply write:
Sometimes it may be interesting to work only on some parts of the image or to extract only a sub set of that image. Olena enables that through the operator ’|’.
Three kinds of that operator exist:
Prototype | Comments |
Image | Sub Domain | Create a new image. |
Image | Function_p2b | Do not create a new image but create a morpher. |
Function_p2v | Sub Domain | Do not create a new image but create a morpher. |
A Sub Domain can be a site set, an image or any value returned by this
operator.
For a given site, Function_p2v returns a value and Function_p2b returns a
boolean. These functions are actually a sort of predicate. A common
Function_p2v is pw::value(Image). It returns the
point to value function used in the given image. C functions can also be used as
predicate by passing the function pointer.
You can easily get a Function_p2b by comparing the value returned by a Function_p2v to another Value. The following sample codes illustrate this feature.
In order to use C functions as predicate, they must have one of the following prototype if you work on 2D images:
In this section, all along the examples, the image ima will refer to the following declaration:
Output:
First, find and label the components.
Then, restrict the image to the sites being part of component 2.
lbl_2 is a new image. lbl_2 looks like:
Finally, create a new color image, fill it with black and fill the sites part of component 2 with red.
The previous example can be written more quickly:
Here is the simple C function used as predicate:
Restrict the image with it:
Output:
When writing:
sub_D must be included in ima.domain().
Let’s have an image, imab, like this:
Extract a sub image from imab with sites having their value set to 1.
Now, if we want to extract a sub image it may fail, depending on the site set used:
If you do not want this constraint, you may want to use an alternative operator: