In Olena, there are both the window and neighborhood concept. A window can be defined on any site around a central site which may also be included. A neighborhood is more restrictive and must not include the central site. Therefore these two concepts are really similar and are detailed together in this section.
By default, structural elements are centered. The central site is located at the origin of the grid: “literal::origin”. With image2d, the central site is (0,0). Centered structural elements must have an odd size.
Name | Description | Representation |
win_c4p | 4-connectivity | |
win_c8p | 8-connectivity |
Name | Description | Representation |
segment1d | 1D segment | - |
Name | Description | Representation |
backdiag2d | Back diagonal | - |
diag2d | 2D diagonal | - |
disk2d | 2D disk | - |
hline2d | 2D horizontal line | - |
octagon2d | 2D octogon | - |
rectangle2d | 2D rectangle | - |
vline2d | 2D vertical line | - |
Name | Description | Representation |
cube3d | 3D Cube | - |
cuboid3d | Cuboid | - |
These predefined windows can be passed directly to a function. The headers are located in mln/core/alias/window*.hh.
Predefined neighborhood:
Name | Description | Representation |
c4 | 4-connectivity | |
c8 | 8-connectivity |
These predefined neighborhood can be passed directly to a function. The headers are located in mln/core/alias/neigh*.hh.
Use case example:
There are several ways to define a new window. The first and the most common way is to declare a window variable and insert dpoints:
This code creates the following window where “X” is the central point from which the window is computed:
o - o X o -
Another way to define the same window is to provide a bool array:
bool b[9] = { 1, 0, 0, 1, 0, 0, 1, 0, 0 }; bool b2[3][3] = { { 1, 0, 0 }, { 1, 0, 0 }, { 1, 0, 0 } }; window2d win = convert::to<window2d>(b); window2d win2 = convert::to<window2d>(b2);
Note that despite the different ways of defining these windows, “varwin” == “win2”. The boolean array must always have an odd size. While creating a windows thanks to a bool array/matrix, the window’s center is the central site of the array/matrix.
Windows are not convertible to a Neighborhood. Neighborhood are convertible to a window though.
A neighborhood has a method “win()” which returns the definition window. Be ware that this window is not centered, thus does not include the central point.