• Keine Ergebnisse gefunden

In the available experimental diffraction images the central electron beam is partly covered by a beamstopper. Since that changes the image significantly (for example reflections may be covered) the modified pixels have to be known. Simply marking the darkest part of the image is not sufficient, because near the image borders the intensity of the rest of the image may also be low and even on the beamstopper may be bright artifacts.

So in this work the delineation of the beamstopper is realized by the use of the snake algorithm, which was described in section 3.2.

4.3.1 Initialization of the snake algorithm

Before the active contour can start to learn the shape of an object it has to be initialized. This could be done by a rough delineation of the user. Since the program should work as autonomously as possible the initialization is done automatically.

The starting point for the initialization is the center determined in the previous section, because the center of the diffraction pattern is always supposed to be covered by the beamstopper. Also the direction of the beamstopper should be known. This

4.3. DELINEATION OF THE BEAMSTOPPER 51 can be estimated by calculating the average intensity on lines of various angles relative to the x-axis starting at the center. The angle with the lowest average intensity should be the angle of the beamstopper.

A rectangle is a good approach for the shape of the initialization. The length of the rectangle in the direction of the beamstopper is limited by the image borders. In the opposite direction the intensity distribution is measured depending on the distance to the center. The lowest value of this distribution is subtracted from all values to remove the baseline and a Gaussian filter with σ = 3 is applied for smoothing (cf.

figure 4.3). The point where the intensity exceeds 50 % of the maximum intensity of this distribution for the first time determines the length of the rectangle in the opposite direction of the beamstopper. The width of the rectangle is set to 40 pixels.

0 10000 20000 30000 40000 50000 60000 70000

0 50 100 150 200 250 300 350 400 450 500

Intensity

Distance to center [pixels]

Figure 4.3: Intensity distribution versus distance to the center measured in the opposite direction of the beamstopper: The point where the intensity exceeds 50 % of the maximum intensity of this distribution for the first time determines the length of the rectangle in the opposite direction of the beamstopper.

Another parameter which has to be chosen is the distance between the nodes of the snake. This parameter is set to 6 pixels. The initialization for the simulated image is shown in figure 4.4.

4.3.2 Application of the snake algorithm

To apply the snake algorithm the intensity gradient in the image has to be known.

The horizontal gradient at the point~p= (x, y) is calculated by the following formula:

Figure 4.4: The initialization of the snake-algorithm for the beamstopper detection is realized by a rectangle. The red points show the nodes of the active contour.

∇phor =

N

X

n=1 M

X

m=1

Fn,mhor I x+m−(M + 1)/2 y+n−(N+ 1)/2

!

(4.2)

The function I(x, y) denotes the intensity at the point ~p = (x, y). The N × M matrixFhor is called filter. The number of rows and columns in this filter is always odd. Because the diffraction image contains no information at the borders and the filter cannot be applied there, the gradient in this area is set to zero. The vertical component of the gradient is calculated analogously.

Using the simple form of the filter in the horizontal direction

Fhor = (−1,0,1) (4.3)

may yield reasonable results for some images. But in many cases the gradient is dominated by noise and not by the edge of the beamstopper. To reduce the noise influence for the calculation of the horizontal component of the gradient a filter of the following form is used [10]:

4.3. DELINEATION OF THE BEAMSTOPPER 53

The filter for the vertical component is given by:

Fvert =

Figure 4.5: The red points show the active contour after learning. The used param-eters are given in table 4.1.

Using these filters and the values in table 4.1 for the parameters defined in section

3.2 leads to the shape of the snake shown in figure 4.5.

ωm ωδI ωg ωδG ωc ωb size 1.85 0.001 7.0 0.0 10.0 6.5 10

Table 4.1: Parameters of the snake algorithm for the beamstopper detection. The parameter size denotes the size of the neighborhood.

In the next step the nodes of the snake are connected and the enclosed pixels are marked as corrupted, which means that they will be disregarded in the following analysis steps. Also points which are closer than 3 pixels to the active contour are marked as invalid. This is necessary because due to the blurring of the beamstopper the active contour might not move exactly to the outer object boundaries.

The beamstopper is in general not circular in the center. In the subsequent analysis steps average intensities dependent on the distance to the center are calculated.

Hence in some directions the beamstopper makes the pixels invalid and in other directions not. This leads to a very small number of valid values for some distances.

A small number of valid pixels also means, that the average in this interval is very sensitive to noise.

Here the used solution to this problem is to add a circle around the center to the beamstopper. The radius of the circle is calculated by measuring the largest distance from the center to the pixels, which are identified to belong to the beamstopper in the directions which differ at least 75 from the beamstopper direction.

The layer lines are not affected by this circle since the radius of the circle is smaller than the distances of the center to the reflections.