Project

General

Profile

Morph-M Python - Structuring Element » History » Version 2

Serge Koudoro, 10/26/2009 11:04 AM

1 1 Serge Koudoro
h1. Morph-M Python - Structuring Element
2
3 2 Serge Koudoro
h2{color:#8B0000;background:#ddd}. Introduction
4
5 1 Serge Koudoro
Structuring elements are the most elementary objects that make it possible to parametrize Morphological operations. Some structuring elements have been predefined, that you can manipulate through their interfaces. 
6
7
And to create your own, you can use usefull factories.
8
9 2 Serge Koudoro
h2{color:#8B0000;background:#ddd}. Neighborhood construction
10 1 Serge Koudoro
11
Hereafter, a little example to construct rectangle structuring element (centered):
12
13
<pre><code class="ruby">
14
def constructRectangeNeighborhood(xSize,ySize):
15 2 Serge Koudoro
    list=[];
16
    for i in range(xSize):
17
      for j in range(ySize):
18
          list.append(i-xSize/2)
19
          list.append(j-ySize/2)
20
    return NeighborListFactory(ConnexityType.Square, 2,list)
21
22 1 Serge Koudoro
sq9x15 = constructRectangeNeighborhood(9,15)
23
ImErode(imIn,sq9x15,imOut)
24
</code></pre>
25 2 Serge Koudoro
26
This sample code could be easily extended to other shapes/dimensions.
27
28
h2{color:#8B0000;background:#ddd}. Documentation