Download as pdf or txt
Download as pdf or txt
You are on page 1of 43

The monitoring of a laser beam

Ingemar Eriksson

Department of Information Technology and Media (ITM)
Mid Sweden University





Abstract
The origin of this project involved the problems associated with variations of the laser
beam in material processing using a laser. The main problem is that a change in the
laser beam profile does not become obvious until the end result begins to fail. To
monitor the beam, the suggestion was to mount a camera in front of the laser, and a
computer would then use the camera images to monitor the beam properties.

The most important property of a laser beam is the width. However, after
implementation of the method in the ISO 11146 standard, the conclusion drawn was
that the method was not suitable for noisy images and investigations were conducted
into alternative methods to calculate the beam width.

The implementations with regards to the monitoring was in terms of max and min
limits for a Kalman-filter that smoothes out the measured values before testing
whether or not the value is acceptable. This combination is capable of detecting
changes within a noisy measurement.

The final result of the entire project was a Labview program that measures and
monitors a laser beam profile.


Sammanfattning
Ursprunget till detta examensarbete var problemen med varierande laserstrlar vid
material bearbetning med laser. Problemet r att en frndring av laserstrlen inte
mrks frrn slutresultatet blir mrkbart frsmrat. Fr att vervaka laser strlen fre-
slogs att en kamera monterades framfr lasern, och en dator som anvnder bilderna
fr att vervaka strlens egenskaper.

Den viktigaste parametern hos laserstrlen r bredden. Nr ISO 11146 standardens
metod implementerades, konstaterades snart att denna metod inte var lmplig fr
brusiga bilder. Drfr undersktes alternativa berkningsmetoder fr att erhlla
strlbredden utifrn bilder tagna av en kamera.

Fr sjlva frndringsdetekteringen implementerades ett Kalman-filter. Denna
kombination visade sig vara mycket effektiv fr att detektera frndringar hos en
brusig mtning.

Hela projektet resulterade i ett Labview program som mter och vervakar en
laserstrles utseende.





Preface

This master thesis is the final step towards my Master Degree in Electrical
Engineering. The work was performed over a 20-week period of full time studies at
Mid Sweden University. The majority of the time was spent in the Laser-laboratory in
stersund where I had access to the high power lasers.

The idea for the project comes from Laser Nova AB in stersund, and I had a great
deal of assistance from my supervisor at the company Rickard Olsson.




Mid Sweden University 2005



Ingemar Eriksson



1

Table of contents
1 Introduction.................................................................................................... 2
1.1 Background............................................................................................. 2
1.2 Problem description ................................................................................ 2
1.3 Goal of the project .................................................................................. 2
1.4 Report structure ...................................................................................... 2
2 Theory............................................................................................................ 3
2.1 What is a laser beam?.............................................................................. 3
2.2 Measurement methods ............................................................................ 5
2.3 Calculation methods................................................................................ 8
2.4 Detection of change ...............................................................................13
2.5 Visualization..........................................................................................15
3 Method and realization ..................................................................................16
3.1 Experimental setup.................................................................................16
3.2 Simulation .............................................................................................17
3.3 Measurement program...........................................................................18
3.4 Monitoring and supervision of the Laser beam.......................................18
4 Results...........................................................................................................19
4.1 How well does the calculation methods work.........................................19
4.2 Possible improvement of the four-sigma method....................................25
4.3 Kalman filter..........................................................................................27
4.4 Simulated beam vs. Real beam...............................................................29
4.5 Labview program...................................................................................30
5 Conclusions and discussion ...........................................................................31
Abbreviations........................................................................................................33
Bibliography .........................................................................................................34

Appendix
A Camera requirements
B Matlab code
C Equipment


2
1 Introduction
It is probable that the reader will require some knowledge about Laser-technology
and Adaptive-filtering to fully comprehend the report although those readers with
mathematical knowledge will understand most of the report.
1.1 Background
Laser Nova is a company offering almost everything within the area of micro
machining with lasers, e.g. welding, cutting, drilling, annealing, scribing and
marking which is performed using Nd:YAG- and CO
2
- lasers. In laser material
processing the quality and shape of the laser beam is fundamental to the end result
and Laser Nova would like to monitor the laser beam continuously in order to gain
better control over the process and thus achieve a better quality end product.

The purpose of the project was to develop and investigate methods to be able to
monitor a laser beam. The system should be able to warn the operator when the
beam properties change.
1.2 Problem description
A high power laser can change the beam profile in numerous ways, e.g. when there
is a temperature change in the active medium, thermal lensing in a Nd:YAG-rod,
unstable resonators etc. Also the shape of laser beam varies due to mirror positions
and pumping power from the light amplifier. The laser mode can change abruptly,
which can cause a dramatic impact on the end result of the product. In real
production it is difficult to see when the changes occur. However it is crucial to
obtain greater control of this parameter in order to avoid situations where products
must be discarded or sent back from the end customer.
1.3 Goal of the project
The goal of the project is to investigate and evaluate methods involved in the
monitoring of Nd:YAG lasers, primarily the beam width, power, astigmatism and
laser mode. Change detectors will also be implemented to give a warning when
there is a parameter change.

One side effect of the monitoring, involves an image of the beam being possibly
used as a tool to make easier adjustments to the laser beam, by visualizing the beam
profile to the operator.
1.4 Report structure
The report starts with a theory section, which explains different ways of measuring
a laser beam and some methods of calculating the beam width from an intensity
image. This section also includes a brief explanation of the Kalman filter and the
CUSUM algorithm. A description of the setup and methods used to evaluate the
calculation methods then follows. The final part of the report contains the results
and conclusions of the project.

References are marked by square brackets [ ]. References to the appendices are
marked using the letter of the appendix. i.e. [B] is a reference to Appendix B. If
there is a number between the brackets then it is a reference to the bibliography.

3

2 Theory
2.1 What is a laser beam?
A brief description of laser technology and some of the vocabulary used is given
below. It is not intended as a textbook chapter on laser technology, but merely as a
brief introduction to those unfamiliar with lasers.

Laser is an abbreviation of Light Amplification by Stimulated Emission of Radiation,
and is a means of creating high power coherent light. The light is amplified by
copying photons in an amplifier. By putting a mirror on each side of the amplifier
the light is multiplied several times thus creating very high light intensity. One of
the mirrors (front mirror) is semitransparent and thus a ray of light will emerge and
a laser beam will be coupled out of the laser cavity (see Figure 1)

Figure 1 A laser cavity
Between the mirrors inside the laser cavity the light will interfere with it self and
create different laser modes. These transversal electromagnetic modes (TEM) can
be categorized according to the number of minima along the X and Y direction (see
examples in Figure 2). These modes can be calculated using 2D-Hermite poly-
nomials.[12] Other types of modes can appear but the TEM modes are those most
commonly found in the literature.

Figure 2 TEM00 TEM01 TEM21
The TEM00 beam is essentially a 2D Gaussian bell curve, the width of the beam is
where the curve exceeds 1/e
2
(=13,5%) of the maximum value. More complex
beams can appear when several modes are combined, e.g. if a TEM00 and TEM01
are combined correctly, an elliptical beam can appear.

A perfect TEM00 laser beam is difficult to accomplish. Often the power in the laser
is decreased when generating a TEM00 beam, as all other modes must be removed.
Some lasers are unable to generate a true TEM00 beam due to the mirror
configuration.

4
By combining several modes, complex beam profiles are created (see Figure 3) and
the total power is the sum of the powers in the modes. In real life the use of an ugly
beam is often sufficient for the required job.


Figure 3 Examples of different laser beam profiles
As the Gaussian profile (TEM00) provides the smallest focus point, this is the
preferred shape for e.g. cutting applications, whereas a flattop beam profile is
preferable for welding, annealing etc.
Laser beams are by nature divergent and the beam will always increase in width
over distance. The least divergent beam is the TEM00 beam. The beam propagation
factor M
2
, is a parameter which describes how much faster a real beam diverges in
comparison to a TEM00 beam. A beam with an M
2
=3.1 will diverge 3.1 times as
fast as a TEM00 beam. The M
2
parameter is an important property of the laser beam
as it describes how easy it is to focus the beam on a surface. The M
2
is usually
calculated by measuring the beam width at several distances from a lens. However,
no standardized method for measuring the M
2
parameter exists.

One of the most common lasers in the industry is the CO
2
-laser with 10.6m
wavelength. This is a gas laser using CO
2
as the active medium in the amplifier.
Another common laser type is Nd:YAG with 1,064m wavelength and this is a
crystal laser using a Neodymium doped YttriumAluminumGarnet rod as the active
medium in the amplifier. Both of these laser types can be manufactured to give a
output power from a few Watts up to several Kilowatts, making them ideal for
material processing. CO
2
lasers often produce the laser light continuously, so called
continuous-wave (CW). Nd:YAG lasers can be operated in pulsed mode, the lamp
driving the amplifier is more efficient in pulsed mode, thus increasing the efficiency
of the laser. These produce milliseconds long pulses of laser light. Alternately the
Nd:YAG laser can be operated in Q-switched mode[9] where nanosecond long
pulses produce high peak power with a low power laser. A peak power of several
Megawatts can be produced with an average power of a few hundred Watts.


The longer wavelength of CO2 makes it possible to obtain light absorption in mate-
rials transparent to visible light e.g. glass and acrylic.

The shorter wavelengths of Nd:YAG laser have a better absorption in metal. Glass
is transparent to the light from Nd:YAG lasers thus making it possible to use an
optical fiber delivery system thus enabling the laser source to be in a different
position to that of the processing point.


5
2.2 Measurement methods
The need for measuring methods means that several, more or less accurate methods
have evolved. Often a method is used merely because it is simple and the alternative
is too complicated or expensive[11].
2.2.1 Laser power
The power of a laser is usually measured by a photodiode, or using calorimetric
methods. The measured power is usually the total power in the beam. If some kind
of imaging measurement is made instead, the power distribution inside the beam
can be observed, making it easier to tune the laser to the desired beam shape.
2.2.2 Laser beam width
If the laser is operating within the visible wavelength region, the simplest
measurement is to project the beam onto a screen, possibly with the use of a beam
expander to enlarge the beam. The image on the screen then enables observation of
the beam width. This method is easy, quick and intuitive. One drawback, however,
is that the human eye has a logarithmic response to light making it difficult for a
qualitative judgment of the beam profile to be made. It is difficult to perceive the
details in the high power areas of the beam. As this measurement is subjective it is
also hard to repeat the measurement and to compare laser beams.
2.2.2.1 Fluorescent material
For invisible laser beams close to visible wavelengths e.g. Nd:YAG, a fluorescent
material can be used to convert the laser light into visible light. In this way lasers
with invisible light can be monitored as if they were emitting light in the visible
area.

One problem with this method is that the fluorescent material may be nonlinear.
Logarithmic or derivative effects can cause even more complications when
attempting to produce a good measurement.
2.2.2.2 Burned spots
One way to examine the beam profile with high power lasers is to allow the laser to
burn a hole in a paper. The shape of the hole represents the shape of the laser beam.
The result is dependent on the length of time for which the paper is burnt and only a
few power levels can be observed within the beam. (Not burnt, burnt and ash.)

The advantages of the method are its simplicity and the possibility to save and com-
pare laser beam profiles. The shortcomings of the method are the bad resolution in
power levels, its slowness and the high power required.

The method is the same even if materials other than paper are being burnt. Wood,
steel and acrylic plastics can be used in order to burn spots, with similar result.

6

2.2.2.3 Moving Knife-edge
To increase the accuracy in the width measurement, better methods have been
developed. The moving knife-edge method uses a large area power detector. A
moving knife-edge is used to cut off part of the laser beam, see Figure 4. By re-
cording the power reaching the detector as a function of the knife-edge position, it is
possible to monitor the beam profile in the cutting direction. According to ISO
11146 [7] the width of the beam is calculated by measuring the positions where
16% and 84% of the beam power are transmitted, but other power levels are also
used. The distance between these positions is the uncorrected beam width and
denoted by d
k
. This width is later corrected to give the same width as the second
order moments width (see section 2.3.2). The correction is individual for different
lasers, modes and M
2
values.

Figure 4 The moving knife-edge method is using a knife to block part of the laser beam
Several knives cutting the beam in different directions can be used, and with com-
puter aided tomography, details in the beam can be recreated. This way a complete
intensity image can be achieved

An advantage of the moving knife-edge method is that it is capable of measuring
small beams (< 1m) and high power beams can be measured with little or no
attenuation.

The method does, however, possess some drawbacks. If the beam is elliptical the
knife should move along the major and minor axes of the ellipse, the scanning
system must be rotated. Because it is a mechanical scanning system it is also
difficult to measure pulsed laser beams, especially if the beam profile changes from
pulse to pulse.

There are several measuring methods using similar techniques, all sharing the same
pros and cons, for example the Moving Slit and the Variable Aperture methods.
2.2.2.4 CCD-camera
A better means of observing details in the beam, in comparison to the moving
knife approach, is by making an array of detectors. For wavelengths in the visible
and near-infrared area a standard CCD-camera can be utilized as a sensor array.
Pyroelectric arrays have bean developed for lasers which operate outside the area
where CCD-cameras are sensitive (400nm-1100nm).
Because standard camera sensors are very sensitive to light, the laser light requires
attenuation before it reaches the sensor. This can be performed via the use of
semitransparent mirrors, which allow a small part of the laser power to pass
through. Neutral Density filters can also be used to attenuate the light. If several

7
filters/mirrors are stacked, it is important to align them in order to minimize
interference phenomena that can distort the image of the beam. Dust on the
filters/mirrors can also seriously distort the image of the laser beam.

With the CCD-camera a complete image of the laser beam is taken at once. This
makes it possible to measure single pulses of lamp pulsed and Q-switched lasers.

After the image is acquired, a computer calculates the width of the beam. There are
several calculation methods available to perform this, some of which are described
in section 2.3.

To perform the measurement of the laser beam in this project, the camera method
was chosen. The main reason for this was that a complete 2D beam profile is
achieved and fast measurements are possible. With some machine vision cameras
single laser pulses can be separated and measured. Also there are cameras available
in reasonable price classes for the intended use.

For this project available cameras and a frame grabber to convert analog camera
signals to digital were used. The cameras proved to be insufficient for measuring
pulsed lasers, as no external trigger was available on the cameras. A short
evaluation of different cameras and their characteristics can be found in appendix A.

It is only possible for a camera to provide an intensity image of the beam. This
image is then processed and the width, power and laser mode are then extracted.


8
2.3 Calculation methods
The goal of the project was to monitor the beam and give a warning if changes
occur. If the laser mode is changed then this will cause the beam width to also
change. This leads to the conclusion that it is best to focus on measuring and
monitoring the beam width, as this will also indirectly monitor the beam mode. The
total power of the beam is proportional to the sum of the intensity in all pixels. It is
difficult to measure the absolute power; all the attenuators need to be calibrated. It is
better to measure the absolute power by other means and only measure the relative
power with the camera, and warn the operator when the power changes.

Looking at Figure 3 it is easy to realize the problem to correctly measure the width.
As Mike Sasnett remark[6]

on a beam similar to the industrial profile: trying to de-
fine a unique width for an irregular beam profile like this is something like trying to
measure the width a ball of cotton wool using a calipers. This offers an insight into
the complexity of the problem.

None of the calculation methods proposed by anyone so far has been successful in
calculating the width for all laser beams. The one coming closest is the ISO 11146
standard which entails a second order moment calculations. The second order mo-
ment of the beam is the 2D-variance. The width of the beam is defined as four times
the standard deviation of the beam.
Other ways to define the width of the beam are;

- The full width at half of the maximum intensity (FWHM)
- The diameter containing 86% of the total power.
- The width at 1/e intensity points
- The width at 1/e
2
intensity points
- The width of the best fit Gaussian beam
- The width of the best fit flattop beam
- The Knife-edge width of 16%-84% power points
- The Knife-edge width of 10%-90% power points
- The Knife-edge width of 5%-95% power points

9

2.3.1 Center of gravity
The equations and figures in section 2.3.1 and 2.3.2 are copied directly from ISO
11146

During automated laser processing the position of the beam is an important prop-
erty.[11] The center of gravity is the best way to represent the center of the beam as
there is an equal amount of power in all directions from the center of gravity. The
center of gravity of a laser beam is the same as the average value of the projection
on the X and Y axes of the image. This is not necessarily the same point as the
maximum power in the beam.

E(x,y) is the beam irradiance (intensity) in the pixel (x,y)
P is the total intensity (power) in the beam, <x> and <y> is the position for the cen-
ter of gravity. All integrals are done over the entire image.
To calculate the center of gravity the following three equations are used:









2.3.2 Variance
The ISO 11146 standard [7] defines the width of the beam as four times the
standard deviation, this leads to the expression four-sigma width sometimes called
the second moment width. If the beam is circular or if it is elliptical and aligned to
the X and Y axes, the beam can be projected on the X and Y axes and the width of
the beam can be calculated from the projections. This will simplify the calculation
but will give a false width if the beam is rotated. To obtain the correct width the
covariance between X and Y is utilized and the width is calculated along the ellipse
axis. If an elliptical beam is aligned to the axes then the covariance becomes zero.
The variances of the projection on the axes are denoted <x
2
> and <y
2
> and the
covariance of the beam is <xy>. These are calculated via the following three
equations

. ) ( ) , ( (
1
and
) )( ( ) , ( (
1
, ) ( ) , ( (
1
2 2
2 2
}
}
}
>= <
>= <
>= <
dxdy y y y x E
P
y
dxdy y y x x y x E
P
xy
dxdy x x y x E
P
x


The beam width closest to the X-axis is calculated using,
>= dxdy .
}
}
}
<
>= <
=
y y x E
P
y
dxdy, x y x E
P
x
dxdy y x E P
) ) , ( (
1
) ) , ( (
1
) , (
and

10




where is ( )
2 2
sgn y x .

The beam width closest to the Y-axis is calculated using
( ) ( ) ( )
2
1
2
2
2 2 2 2
2
1
4 2 2

+ + = xy y x y x d
y

o

The azimuthal angle from the X-axis to the closest axis of the beam is calculated
using


.



Figure 5 Calculated width and angel of a beam.
(In Figure 5 the width is denoted D instead of
o
d , this is directly copied from the
ISO 11146 standard for no particular reason.)

As this method is giving more weight to the values far from the center of gravity,
the method is very sensitive to noise and offset in the image. A small positive offset
level will be included in the calculated width and the result will be false. The fun-
damental problem associated with the four-sigma calculation method is to find the
correct offset level. If the correct offset level is subtracted from the image then the
calculations will produce the correct four-sigma width.
|
|
.
|

\
|

=
2 2
2
arctan
2
1
y x
xy

)
d ( ) ( ) ( )
2
1
2
2
2 2 2 2
2
1
4 2 2


`





(

(



+ + + = xy y x y x
x

o

11

Figure 6 Profile of a beam from an image.
2.3.3 Software Moving Knife-Edge
A software version of the moving knife-edge measurement can be made by setting
pixel intensities to zero when the knife-edge is moving across the image. The power
is measured by summing the intensity of all the pixels. The simple calculations of
this method and as it is less sensitive to noise than the variance based four-sigma
calculations have made the software calculations popular in existing beam profiling
programs. The fact that the hardware (section 2.2.2.3) version is approved in the
ISO 11146 standard is clamed as proof that the software version also is an approved
standard. However the software version is never mentioned in the standard.

Advantages over the hardware version are that the CCD-camera can be used on
pulsed beams, and that the direction of the knife can rotate in software making it
follow an elliptic beams major axis.
2.3.4 Threshold
An easy method to separate the beam from the background is to threshold the image
at a specific level. All pixel values above the level is set to one (illuminated), all
pixel values below the level are set to zero. By counting the number of illuminated
pixels along a line intersecting the center of the beam, the width of the beam is
found. If the threshold level is set to 50% of the maximum intensity, the FWHM
(Full Width Half Max) is received. If the beam is a TEM00, a level of 13.5%
(=1/e
2
) will give the same width as the four-sigma method. Other threshold levels
can also be used for example 1/e, depending on the beam profile.

As in the moving knife calculation it is necessary for the width to be calculated
along the principal axis of an elliptical beam and these directions can be found by
numerous methods. One method is to place the coordinates for the pixels above the
level in a matrix A. Then calculate the principal components of the illuminated area
by calculating the eigenvectors of A*A
T
. The eigenvectors will be pointing in the
direction of maximum and minimum variance showing the directions of the axes of
the ellipse. If the matrix A is big, the calculation of A*A
T
will be time consuming
making this algorithm less suitable for online calculations.

It might be faster to calculate the beam width along several directions and find the
axes of the ellipse by trial and error. There will be a small error in the angle, but for
bigger beam sizes the calculation is a great deal faster than the eigenvector method.
For circular beams higher precision is achieved by taking an average of the diameter
in several directions.

12

2.3.5 Offset
Images from a camera always contain noise. The noise can be divided into two
parts; a high frequency random noise originating from electrical noise in the sensor
array and a constant offset level originating from ambient background light. The
high frequency part is difficult to deal with in a single image. However, an average
of several images can reduce the high frequency noise but this makes it difficult to
detect sudden changes. The offset can be subtracted from the image as a correction;
the problem is to find the correct offset to subtract from the image. The four-sigma
method is very sensitive to offset errors.

The ISO standard carefully describes methods to reduce the offset error. The first
thing to do is to check if the offset is uniform, which is performed as follows. Block
the laser beam and take an average of a minimum of 10 images, which will
minimize the effect of high frequency noise. The average image is the background
map and should be subtracted from images before calculating the beam width. If the
variance in the background map is less than the high frequency noise variance then
it is sufficient to subtract a constant offset level from all pixels.

It might be sufficient to utilise an average image background map. However, if light
from the pumping lamps in the laser amplifier or stray laser light reaches the camera
the offset will increase when the laser is on. This means that it might be necessary
to calculate the background map while the laser is on. To do this, it is necessary to
calculate an offset level from those pixels not illuminated by laser light.

The background offset is divided in to the mean value E(offset) and the standard
deviation
offset
. In the ISO standard all pixels satisfying E(x,y)> E(offset)+n*
offset

are illuminated. (the n value is between 2 and 4) The rest of the pixels should be
included in the calculation of a new offset level.

The values E(offset) and
offset
can be calculated by using non-illuminated areas
from the corners of the image. To overcome the error from the quantization of the
image intensity, a moving average of the image is calculated (A 2D-convolution
map of ones divided by the size of the convolution map). When a blurred image is
used to determine whether or not a pixel is illuminated, the threshold level can be
set to parts of a greyscale value.


13
2.4 Detection of change
To detect and give an automatic warning is not a problem specific to this project; it
is required in many surveillance systems. A change can be either an abrupt change
to a new level, or a slow gradual change.

2.4.1 Max-Min limits.
This method is basically to check whether the measured value is within a predefined
interval. If any of the measured parameters is outside the desired interval an alarm
warns the operator. To reduce the false alarms caused by noisy measurements the
Max-Min test is preformed on the filtered values from the Kalman filter
2.4.2 Kalman filtering and CUSUM
The Kalman filter was first derived by R.E. Kalman in 1960 [1]. The filter is the
optimal filter for the estimation of a random signal distorted by white noise.

The filter is based on a state X that is changed by a transition matrix A. The state is
also assumed to vary with a normally distributed process noise with variance Q as

X
(t)
=A*X
(t-1)
+ N(Q).

A measured quantity Y can be derived from the state X via a state transition matrix
C. The measurement is disturbed by measurement noise with variance R. This can
be written as

Y=C*X + N(R).

In the Kalman filter, a state X

is estimated first. Then the covariance P for the


estimate is calculated and at a later stage, a correction is made to the estimated state
to provide a better fit with the actual measured value Y. The Kalman amplification
factor K decides how much correction is made.

Figure 7 The Kalman-filter is basically five equations
X

(t|) : Estimate of the state at the time t, given the measurement up to time
Y() : Measurement at the time
P : Covariace of the estimation error .
K : Kalman amplification factor.

Using Kalman filtering means relatively few calculations when the transition matri-
ces are known. Also if the variance of the measurement noise R and process noise Q
are constant, then K and P are constant and can be calculated in advance thus reduc-
ing the number of calculations.

14

If the state is constant (for example a direct current) A=1 and measured directly
C=1 then the Kalman filter will converge to a one tap IIR filter. The problem
associated with Kalman filters in general is to find the correct variance of R and Q,
once this is done the Kalman filter is the optimal filter for the task.

The difference between estimated value and measured value is the so-called residual

c(t) = Y(t)-C* X

(t|t-1).

If the estimate is correct the residual is white noise with zero mean. When the esti-
mate differs from the true state the residual mean is non-zero.

The CUSUM algorithm adds the residuals over time, and the sum is written as

g(t) = max[0,(g(t-1)+ (c(t)-u))],

where u is a drift factor. When the sum g(t) exceeds a value h a change is detected.

g(t)>h Alarm

By setting the cumulated sum g(t) to zero while the residual is smaller than u, the
CUSUM alarm time is shortened.

To detect changes when the true state decreases the sign of the residual is changed,
i.e.

c(t) = C* X

(t|t-1) - Y(t).

The values of u and h decides how sensitive the CUSUM is and how fast the alarm
reacts on changes, and are design parameters.

When a change is detected either a warning to the operator is sent out or the Kalman
gain K is changed so that the Kalman filter will have a faster response.

15

2.5 Visualization
The visualization of the beam is a simple task to perform when an image is acquired
to a computer. A black and white image is basically the same as looking directly at
the beam, by representing different intensity levels as colors the operator can more
easily distinguish the levels. An even better way of visualizing the beam is to plot a
3D graph and combine this with colors, see Figure 8.



Figure 8 3D visualization of a TEM00 beam

16

3 Method and realization
To monitor the laser beam a camera was chosen to acquire an image. To calculate
the width of the beam the ISO standard variance calculation was implemented.
However, the variance calculations proved to be extremely sensitive to noise and
offset in the image. To obtain more stable measurements usable to detect changes
the threshold method was chosen and this method can calculate several widths
simply by adjusting the threshold level. 50%, 36.8% (1/e) and 13.5% (1/e
2
) are
standard levels.

I chose to investigate and implement Max-Min limits to detect slow changes and to
use Kalman filtering to remove noise from the measurements. CUSUM [4]
detection
is
implemented using the estimation residual in the Kalman filter to provide an alarm
if rapid changes occur. This is a known means of detecting changes, suitable for
noisy measurements and stochastically varying processes.
3.1 Experimental setup
To test the calculation models and the camera on a real laser, a test bench was set
up. A Siemens Nd:YAG laser capable of 25W CW (Continuous wave) was used as
a laser source. A standard 90 deg. mirror found in ordinary laser systems deflected
most of the laser power into an aluminum block used as a beam dump. In a real
system this part of the beam would be used for material processing. A small part of
the laser light usually passes through these mirrors. A 99.9% rear end mirror was
used as the attenuation. Neutral Density filters might have proved to be a better
option as they attenuate all wavelengths equally, but were unavailable at the time. In
front of the camera a narrow bandpass filter was mounted to reduce noise from
other light sources (such as lamps in the room and the pumping lamp of the laser).

Figure 9 Basic experimental setup
The setup in Figure 9 was used for several cameras to test their characteristics. The
analog cameras were used together with a frame grabber to obtain the images for the
computer. The frame grabber was a home consumer type, and was not supported in
LabView. An available web-camera compatible with LabView was used to monitor
a beam in real-time.

The programs for monitoring and visualization of the beam were developed in Lab-
View. This offered an easy means of obtaining a graphical interface for the operator
and a graphical programming environment for the author of this report. There is

17
support for standard industrial cameras in LabView, thus making it possible to
change the camera without changing the software.

3.2 Simulation
To verify and examine the calculation methods, simulations were carried out in
MATLAB, which enabled it to be possible to have total control over the beam
width, ellipsity, noise and offset. To simplify the evaluation of the calculation
methods, the width calculations were made in MATLAB, so no conversion to
LabView were necessary.

The four-sigma method and threshold method were implemented in MATLAB. The
threshold method was implemented in two versions, eigenvector and trial and error
method to calculate the angle of an elliptical beam. The methods gave the same
results for circular beams, but the eigenvector method was slower so most of the
results are based on the trial and error method.
As the four-sigma method was very noisy an improvement to the method was
implemented at the end of the project, see section 4.2.

The reason for simulating laser beam images was to examine the problems within
the two width calculations methods, mainly focusing on the noise and offset in the
images.
3.2.1 Simulation of laser beam
Perfect Gaussian (TEM00) laser beams were mostly used because of their optimal
beam shape. But algorithms for elliptical beams, and arbitrary TEMxy beam based
on Hermite polynomials were also developed for evaluation. The width in the X and
Y direction, possible rotations and the center of the beam were used as input
parameters.


Figure 10 Test image size 240x320, with a simulated 100 pixel wide TEM00 laser beam. Equal
to 41% of the image height and 31% of the image width. The maximum intensity of the beam
was 60% white (153 of 255). An offset of 20 was added to the image. This was the starting point
for most tests.

18

3.2.2 Simulation of noise
After a laser beam profile had been calculated, Gaussian noise with variable vari-
ance and average was added to the image. This noise was assumed to be sufficiently
good to represent the offset and noise that occurs in real images from a camera.
The image was then quantized to an 8-bit grayscale.
3.2.3 Simulation of changes
In order to test the change detection capabilities of the Kalman filter, simulations
were performed of laser beam films with sudden changes were simulated, also just
noisy values with sudden changes were simulated to mimic the values received from
the width calculations.

3.3 Measurement program
Programs/functions to measure the beam parameters were developed in both
MATLAB and LabView. As far as possible the software was built in modules,
making it possible to reuse functions and subVIs in the future.

MATLAB was used to evaluate the characteristics of the different calculation
methods. This eliminated the problem with conversion of the simulated laser beams
into a format LabView accepts.
In LabView programs usable for practical purposes were developed for real time
presentation of data, image processing and monitoring of the laser beam.

To visualize the beam profile more clearly, the ability to display the beam as a 3D-
graph was implemented within the LabView programs.
3.4 Monitoring and supervision of the Laser beam
Monitoring programs were developed in LabView. The possibility to use either
four-sigma or threshold calculations was implemented to be able to switch to the
most suitable. The ratio between the major and minor axis and the angle of an
elliptical beam was also monitored.

In real beams, there often several areas with higher intensity then the average in the
beam. To detect changes in these so called hotspots a laser mode detection
method was implemented in LabView. A Threshold level was manually set by the
user, and then a particle analysis was preformed on the threshold image. The parti-
cle analysis in LabView can calculate the Center of gravity, area and position of the
separate particles. By monitoring the properties of the particles a type of mode
change detection has been achieved. This method was not examined further because
of time constraints and because of the lack of scientific method, but it may prove to
be a useful method for monitoring the lasering mode. The lack of time prevented
this "mode" analyze to be tested on real laser beams in order to investigate the
efficiency.

To simplify the adjusting of the laser a visualization module was added to the
monitoring program. A 3D model of the real beam similar to that shown in Figure 8
makes it easier to apprehend the beam shape.

19

4 Results
4.1 How well does the calculation methods work
To test the calculations methods, simulations of laser beams were used for the four-
sigma and threshold methods. Unless otherwise stated, the image in Figure 10 was
used in the simulation.
4.1.1 Offset level
To test the effects of subtracting a faulty offset level, the subtracted offset was set to
a fixed value and introduced to the calculation models.

When applying a positive error to the offset level, a systematic error of the width
appears in the four-sigma method. All pixel values higher than zero make a
contribution to the beam width, and when the whole image is higher than zero the
calculated width is increased. The four-sigma calculations have a systematic error
of 55% in the X-direction with the introduction of an offset error of one grayscale
level to Figure 10.
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
100
110
120
130
140
150
160
Offset error
(Grayscale levels)
C
a
l
c
u
l
a
t
e
d

w
i
d
t
h

i
n

p
i
x
e
l
s
X-Direction
Y-Direction

Figure 11 An error is produced by an offset error in the four-sigma calculations. The simulated
beam size was 100 pixels

The systematic error is larger if the beam size is small in comparison to the image.
This is the reason for the error in the X-direction being larger (beam size 31% of
image) than in the Y-direction (beam size 41% of image), see Figure 10.

Figure 12 shows the error of the width calculation in images with an offset error of
0.1 grayscale levels, the beam width in this simulation is altered to test the effects of
different sizes. The figure shows an exponential behavior in the error showing that it
is important to attempt to have a large beam size in comparison to the image size.
This is particularly true if the background light is fluctuating thus not enabling the
offset level to be averaged to the correct value.

20
15 20 25 30 35 40 45 50
0
20
40
60
80
100
Beam width in percentage of image size.
P
e
r
c
e
n
t
a
g
e

e
r
r
o
r

i
n

c
a
l
c
u
l
a
t
e
d

b
e
a
m

w
i
d
t
h

Figure 12 Error in width calculation with 0.1 grayscales error in offset

The threshold method is less sensitive to error in the offset. If the zero level is
moved, the cutoff level is also moved, giving a systematic error insensitive to the
beam/image size ratio. The effect is not as dramatic as in the four-sigma method,
less than an 8% systematic error in width occurs with an offset error of 5 grayscale
levels in a 100 pixel wide beam. An error of 5 grayscale levels in the zero level will
change the offset level from 13.53% (1/e
2
) to 10.3% when the maximum intensity is
183 levels and the true offset is 20 levels. If the beam profile has steeper edges than
a Gaussian beam, the reduction in the width error will be even greater than for the
threshold method.
4.1.2 Beam size
When the laser beam is large, a significant amount of energy falls outside the sensor
array and the calculated width is smaller than the actual beam size. The four-sigma
method begins to fail when the beam size is bigger than 60% of the image size, see
Figure 13. This shows that there is a limit to the size of the beam in comparison to
the image.
0 20 40 60 80 100 120 140
-25
-20
-15
-10
-5
0
5
Beam width in percentage of image size
P
e
r
c
e
n
t
a
g
e

e
r
r
o
r

i
n

c
a
l
c
u
l
a
t
e
d

b
e
a
m

w
i
d
t
h
.

Figure 13 Four-sigma calculation error on big beams
The threshold method produces a correct width to the point where the beam is the
same size as the image. Larger beams are set to the image size.


21
For small beams the influence quantization of pixels becomes clear in the threshold
method, see Figure 14. If an average width in several directions is used, then the
effect of quantization is decreased. This simulation was free from noise and the cor-
rect offset level was used in the four-sigma calculations.


0 5 10 15 20 25 30
0
5
10
15
20
25
30
Beam width (pixels)
C
a
l
c
u
l
a
t
e
d

b
e
a
m

w
i
d
t
h

(
P
i
x
e
l
s
)
Four sigma
Threshold

Figure 14 Small beam size
4.1.3 Light intensity
If the intensity of the laser beam exceeds the saturation level of the camera, the cal-
culated beam width will increase in both methods. With an overexposure of 50% the
four-sigma method shows a 3% error and the threshold method a 10% error. When
overexposing by 400% the errors increase to 18% and 30%, respectively.
4.1.4 Noise
To test the noise robustness a 500-frame movie was simulated. Every frame was
composed of the image Figure 10 with Gaussian noise added. The standard
deviation of the noise was equal to the frame number divided by 100. This gave the
error in calculation of the methods as a function of the noise in the image. All cal-
culations in section 4.1.4 were performed using the same movie.


22

Figure 15 Four-sigma calculations
Figure 15 shows the results of the four-sigma method when subtracting the correct
offset value. The errors are produced by the noise in the image.

The same movie was used with threshold calculations, the width in several direc-
tions was calculated and the maximum, minimum and mean widths are displayed in
Figure 16. It should be noted that there was no guarantee that the max and min
widths were perpendicular.



Figure 16 Threshold calculations


23

Figure 17 Threshold of image on a noisy image
The threshold of a noisy beam will produce a fussy edge see Figure 17 and the
width calculation will be noisy. There is also a negative systematic error produced
by the fussy edge. By applying a 7x7-averaging filter to the image before the
threshold the image is blurred, the threshold of a blurry image will have a sharper
edge thus the noise affect on the threshold is reduced.


Figure 18 Threshold calculation of filtered images

24

4.1.5 Offset
As seen in section 4.1.1 the four-sigma method is sensitive to errors in the offset.
The calculated offset is affected by noise as seen in Figure 19. This calculation uses
n=2 for the threshold determining whether or not a pixel is illuminated. If a larger
value is chosen for n, then illuminated pixels will be included in the calculation of
the offset. This will increase the calculated offset level, and a systematic error will
appear in the calculated width.

Figure 19 Calculated offset level
The same calculations as in Figure 15 but using the calculated offset from the corner
pixels instead of the fixed and true value shown in Figure 20 (Note the scale). This
demonstrates the consequence of unstable offset level.


Figure 20. Four-sigma calculated with calculated offset.
To obtain a better estimate of the offset in real images, one method is to include all
the non-illuminated pixels in the offset. However a problem is if illuminated pixels
are included or positive noise excluded, as this introduces a systematic error into the
width calculations, thus the threshold level (n=2-4) must be chosen with care! An
averaging filter or Kalman filter can remove frame to frame noise from both the
offset level and the calculated width. An averaging 2D-filtering (blurring) of the
image can assist in decreasing the high frequency noise, but the problem of finding
the correct offset level still remains.

25

4.1.6 Angle
The ISO standard four sigma calculation gives the angle of an elliptical beam. If the
eigenvectors of the threshold image are calculated the same angle is received as
long as the major axis of the ellipse is closest to the X-axis. The four sigma method
calculates the angle to the axis closest to the X-axis, while the eigenvectors give the
angle between the major axis of the ellipse and the X-axis.

If the eigenvectors of a circular beam 100 pixels wide are calculated, the coordinate
vector A is almost 8000 elements long. Thus the calculation of A*A
T
is slow. As
an alternative method, the width of the beam along every 5 degrees is calculated and
the longest width is set as the major axis of the ellipse. This trial and error method
will quantize the angle, but the calculations are faster for large beams.

To test the angle calculation methods an elliptical beam was rotated in different an-
gles. The major width of the ellipse was twice as long as the minor width. The
simulated angle was compared with the calculated angle from the different methods,
see Figure 21. The four-sigma method displays the angle to the minor-axis when the
angle to the major-axis exceeds 45 degrees.

Figure 21 Angle calculation

4.2 Possible improvement of the four-sigma method
The major problem concerning the four-sigma method is the offset sensitivity.
Noisy calculations of the offset produce massive noise in the width calculations. As
seen in Figure 12 the error in the width calculations is dependent upon the extent to
which the beam fills the image. Carlos B. Roundy[8] suggests that the beam width
be measured initially using a software-knife edge and subsequently apply a software
aperture around the beam. An aperture twice as large as the beam size will reduce
the noise in the four-sigma calculations.

As an alternative to this method I suggest that the pixels determined to be non-
illuminated in the offset calculations are set to zero after the offset level has been

26
subtracted from the image. By this means, it is the noise level in the image that
determines how much of the beam is cut off, not the beam width. In Figure 22 noise
of 5 gray levels in standard deviation was added to Figure 10. The light green areas
were deemed to be non-illuminated when n was set to 2. thus giving an approximate
2X aperture to the image. However, the calculation has already been completed
during the calculation of the offset level.


Figure 22 Non-illuminated pixels as Green
The same simulation as in Figure 20 (with a different noise seed) but calculated
after setting the non-illuminated pixels to zero gives the result in Figure 23


Figure 23 Improved four-sigma calculations
The improvement is clear and is easier to implement the method suggested by
Carlos B. Roundy. One problem occurring with the method is the choice of the
correct value for n. A value of 4 will result in including illuminated pixels in the
offset level and setting them to zero. This will introduce a systematic error into the
calculated width.





27
4.3 Kalman filter
The following examples shown here are simulated values. The first example shows
a constant level of 5 distorted by measurement noise before the filter. As seen in
Figure 24 the Kalman filter follows the measurement from the beginning, the
Kalman constant K is reduced as the filter adapts and places more and more trust in
the estimated value.


Figure 24 Constant level

Given the correct variance for measurement noise Q and the process noise R, the
Kalman filter is the optimal filter for separating signal from noise. See Figure 25.
The problem is to find the noise variance in an unknown system.

Figure 25 Noisy value corrupted with measurement noise
When a sudden change occurs, the Kalman filter will slowly adjust to the new
value. In Figure 26 it is clear that the Kalman filter is too slow to follow the abrupt

28
change of value. One standard approach to obtain a more rapid response from the
Kalman is to temporarily increase the estimation covariance P by orders of
magnitude.
It is also apparent that the residual or the error in estimated value and measured
value is non-zero mean noise.

Figure 26 Abrupt change and slow Kalman filter
The fact that the residual have a non-zero mean makes the CUSUM change detec-
tion effective. In Figure 27 the alarm multiplies the estimate error P by 1000. This
makes the filter fast after the alarm and gradually slower as the filter adapts. Large
changes will trigger the alarm faster, and if the change is small or slow it may pass
undetected.

Figure 27 Abrupt change, slow Kalman filter and CUSUM change detection

29

4.4 Simulated beam vs. Real beam
4.4.1 The beam profile
The industrial lasers seldom have a TEM00 beam. Often maximum power is pre-
ferred over a pure TEM00 mode, which makes the parameter of absolute width less
usable in practice. The beam width is necessary for calculations of the beam propa-
gation factor M
2
, but here only the four-sigma method is valid for direct calcula-
tions. Other methods require compensation to give the correct M
2
for different beam
profiles and wavelengths.

An example of a real laser beam image is shown in Figure 28. The beam profile is
closer to flattop than Gaussian, but there are clear circular modes in the beam and
some areas with higher energy.


Figure 28 Image of real laser beam.
4.4.2 The noise
For the real images, it is not certain that the offset level is constant over the whole
image, a background map is necessary instead of merely an offset level. The noise
in the real images resembles Gaussian noise. The standard deviation varies between
different cameras. For those cameras used in this project, the standard deviation
varied from 2 to 5 greyscale levels. The mirrors used to attenuate the beam were not
completely clean, resulting in interference patterns appearing in the images. The
interference patterns are difficult to see in Figure 28, but when the mirror were
moved, the phenomenon was clearly visible. Some stray laser light is visible in the
lower left corner, which disturbs the calculations.


30

4.5 Labview program
The end results of the project become a Labview program capable of measuring and
monitoring a laser beam. Several versions of this program were developed and the
version in Figure 29 used a pre-recorded movie of a laser beam. The reason for this
was that the frame grabber used for the project was not compatible with Labview.
However, a version capable of real-time surveillance utilizing a USB web camera
was also programmed.



Figure 29 Monitoring program in Labview.

The program calculates the width of the beam either by the threshold method or the
second moments calculation from the ISO standard. The center of gravity and the
width are then plotted in a graph so that the operator can observe the development
over time. The program is also able to warn the operator if something changes.

31
5 Conclusions and discussion
An obvious conclusion is that the four-sigma calculation method described in
ISO11146 is more sensitive to noise than the threshold method. The ability to detect
changes decreases with the amount of noise, thus for the efficient detection of
changes, low noise measurements are preferred. The threshold calculation method is
less sensitive to noise and offset error and produces a smother width calculation.
However, the width is not necessarily the true width of the laser beam.

The ISO 11146 standard can have systematic errors if the offset is not correct. When
the offset level is calculated from non-illuminated pixels the noise in the offset level
is reduced. However, if illuminated pixels are included, an error in the offset will
introduce a systematic error, which also occurs if positive noise is assumed to be
illuminated pixels. This offset error will decrease if all non-illuminated pixels are
set to zero.

The size of the measured beam should be well adapted to the image size and small
and big beams will introduce a systematic error if the four-sigma method is used
and the offset is not perfect. An alternative is to cut the image to a smaller size. This
reduces the image resolution but the sensitivity for imperfect offset levels is
reduced. The average offset can be used instead of the momentous offset; the offset
should not change when the width changes so no error is introduced. Thus a better
offset value is achieved if the values are filtered frame by frame.

By setting the pixels marked as non-illuminated to zero the size of the image is
automatically cropped to a smaller size thus reducing the impact of the noise. Also
this method sets pixels to zero based on how noisy the image is and not based on the
beam size as in the method used by Carlos B. Roundy [8].

Kalman filtering can estimate the true value from noisy measurement and by using
CUSUM, changes can be efficiently detected. The problem is to set the parameters
in the Kalman filter and the CUSUM test correctly. The CUSUM cannot detect slow
changes because the residuals from a Kalman filter will remain at zero mean as the
filter adapts, therefore a max and min limit are required to obtain an alarm for slow
changes. If these limits are set after the Kalman filter, then measurement noise will
not produce false alarms.

To achieve good result several methods should be used. To monitor the beam for
abrupt changes, the threshold method gives low noise measurements which are
easily monitored for changes. However if a more scientific measurement is made,
an average of several images will reduce the noise before calculations, and the four-
sigma method can be used.

The goal of the project was to develop a system to monitor a laser beam. However,
this was not completely fulfilled, mainly because of the need for a better camera.
The camera should preferably be digital with external control over the shutter. This
would make it possible to control the camera via software and adjust the camera
from the same computer program monitoring the beam width. The Labview
program described in section 4.5 was only tested in the experimental set up in

32
section 3.1, so the program probably requires a great deal of additional work to
ensure that it will work in a real-life application.


33
Abbreviations

CCD Charge Coupled Device (sensor array found in high-grade cameras)

CMOS Complementary Metal Oxide Semiconductor

CO
2
Carbon dioxide (Gas used in a type of laser)

CUSUM CUmulative SUMmation (Method to detect changes)

FWHM Full Width Half Max (A way to measure the width of a laser beam)

LASER Light Amplification by Stimulated Emission of Radiation

Nd:YAG Neodymium doped Yttrium Aluminium Garnet crystal
(Used in a type of laser)

PIXEL Picture element (A element in a 2D matrix)

TEM Transversal electromagnetic mode

34
Bibliography
Books

[1] Signalbehandling, F.Gustafsson, L. Ljung & M. Millnert
ISBN:91-44-01709-X

[2] Optoelectronics an introduction, J.Wilson, J Hawkes
ISBN:0-13-103961-X

[3] Digital Image Processing, Second edition, R. Gonzalez & R. Woods
ISBN:0-201-18075-8

[4] Adaptive Filtering and Change Detection, F. Gustafsson
ISBN:0-471-49287-6

Technical reports
[5] CCD vs. CMOS:Facts and Fiction, Dave Litwiller
January 2001 issue of PHOTONICS SPECTRA Laurin Publishing Co. Inc.


[6] How to (Maybe) Measure Laser Beam Quality, A. E. Siegman
Tutorial presentation at the Optical Society of America Annual Meeting Long Beach,
California, October 1997

[7] SIS-ISO/TR 11146-3:2004, Provningsmetoder fr laserstrlens bredd,
divergensvinkel och strlpropagationsfaktor. (ISO 11146-3)

[8] Current technology of laser beam profile measurements,
Carlos B.Roundy

Internet

[9] Hemsida fr laserteknik, LTH 2005-04-07
http://kurslab.fysik.lth.se/FElaserteknik/


[10] National Instruments
http://www.ni.com 2005-03-07

[11] Spiricon
http://www.spiricon.com 2005-03-15

[12] Laser Spatial Modes 2005-05-24
http://www.mathcad.com/Library/LibraryContent/MathML/laser.htm

[13]


1

Appendix
Appendix A: Camera requirements

Here follows a brief description of CCD-cameras and some recommendations
regarding the type of camera usable as a laser beam measurement instrument.

CCD (Charge Coupled Device) is the technology used to read out information from
the pixels in the camera. Light is integrated as charges in each pixel during the
exposure time, then the charges are transported through the CCD-array to an
amplifier, and possibly to an A/D converter if it is a digital camera.

There are several different techniques for performing the readout in CCD-cameras.
One technique is to read out line by line (field transfer) and amplify immediately.
Alternatively, the CCD-array is made twice as big, but only half is exposed to light.
Then the whole image is transferred to the storage area and read out at a later stage
(frame transfer).

According to Carlos B.Roundy[8] a ghost image is created in the field transfer
cameras when used with Nd:YAG laser with the wavelength 1064nm. The light
penetrates deeply into the electronics in the CCD-array and the ghost image appears
when a pulsed laser is used and charges linger in the complex interline electronics of a
field transfer camera. This project had no access to a fast pulsed Nd:YAG laser and
this phenomenon has not been observed. Lately progressive scan cameras have
become available but the response of these cameras has not been investigated.

The fact that the four-sigma method is sensitive to noise and fluctuating offset means
that it is essential to use high quality cameras in order to achieve good
measurements. There are cooled CCD-cameras available, these cameras have lower
dark current noise.

To be able to measure pulsed lasers it is necessary to control the exposure of the cam-
era. This is easier in digital cameras that do not need to be synchronized to a monitor.
Also it is practical to be able to control the exposure time so that single laser pulsed
can be measured. As the laser pulses are very short it is necessary that the whole
image is exposed instantaneously, i.e. a global shutter is required. It is important to
control this as most modern cameras have a rolling shutter, that only exposes a part of
the image at any given time..

Not long ago CMOS (Complementary Metal Oxide Semiconductor) technology was a
cheap and noisy way to produce web cameras. However, recently CMOS cameras
with high quality have become available. An advantage of these cameras is that the
pixel values can be read out individually, this makes it possible to read out only the
interesting part of the image, and at a higher frame rate. For the same reason as
previously, it has not been possible to investigate the effect of 1064nm light on
CMOS technology, but probably noise will increase due to light interference deep
inside the detector. Digital CMOS cameras are available with an IEEE 1394
(Firewire) interface standard called IIDC used by digital machine vision cameras.
This makes it easer to develop computer programs for the calculations of the acquired
image.

2
Appendix B: Matlab code
All MATLAB-code is written with Swedish comments.

Function that generates a noisy film of a TEM00 laser beam that can be made elliptic
and rotated.

function ut=laser_sim2()

%===KONSTANTER==============================
frames=90; %Antalet bildrutor
storlek=100; %Bildens stolek i x och y led
X=50; %Centum fr strlen
Y=50;
DiaX=40; %Diametern fr strlen
DiaY=10;
vinkel=45/(2*pi); %Vinkeln mot x-axeln
intensitet=0.6; %maximum fr strlen utan brus
offset=20/256; %20 bitars offset
noise=(3/256)^2; %Vitbrus med 3 bitars standardavvikelse.
%===========================================

radieX=DiaX/4;
radieY=DiaY/4;
A1=sqrt((2*pi*radieX*radieY)^-1);

%Stega igenom alla bildrutor.
for a=1:frames

%Stegar igenom alla bildpunkter
for x1=1:storlek
for y1=1:storlek

%Rotera kordinatsystemet
x=(x1-X)*sin(vinkel)-(y1-Y)*cos(vinkel);
y=(x1-X)*cos(vinkel)+(y1-Y)*sin(vinkel);

%Berkna intensiteten fr aktuell bildpunkt
A(x1,y1)=A1*exp(-0.5*((x/radieX)^2+(y/radieY)^2));
end
end

%Skala om s maxvrdet = intensitet
skala=intensitet/max(max(A));
B=A*skala;

%lgg p brus
C = imnoise(B,'gaussian',offset,noise);

%Klippbort <0 och >1
C=max(C,0);
C=min(C,1);

%Kvantisera till 8bit
C=round(C*256)/256;

%Spara undan aktuell bildruta
ut(:,:,a)=C;
end

3
Function that calculates the FWHM along the eigen vectors of the bam

function ut=threshold(infilm)
[a,b,c]=size(infilm);

%Stegar igenom filmen bild fr bild
for frame=1:c
%Extraherar aktuell bildruta
profil=infilm(:,:,frame);

%Gr threshold av aktuell bild vid 50% av amplituden
maximum=max(max(profil));
minimum=min(min(profil));
bw=im2bw(profil,((maximum-minimum)*0.5+minimum));

vektorer = [0 0]';
n=1;
%gr en vektor med koordinaterna fr "upplysta" pixlar
for x=1:a
for y=1:b
if bw(x,y)
vektorer(:,n)=[x -y];
n=n+1;
end
end
end

[e1,e2]=size(vektorer);

%medelpunkten av ljusa bildpunkter
medel=sum(vektorer')/e2;
%Justera koordinaterna s att de r centrerade runt noll
vektorer=vektorer-(medel'*ones(1,e2));
%Berknar egenvektorerna
C=(vektorer*vektorer');
[V D]=eig(C);

%Rkna antalet pixlar frn centrum ut till kantan p strlen
%Stegar lngs egenvektorerna/principalaxlarna t fyra hll
for temp=1:4
x=round(medel(1));
y=round(-medel(2));
langd(temp)=0;
while bw(x,y)==1
%gr framt/bakt ett steg
langd(temp)=langd(temp)+temp-round(temp/2)*4+1;
x=round(medel(1)+V(round(temp/2),2)*langd(temp));
y=round(-medel(2)+V(round(temp/2),1)*langd(temp));
end
end

vinkel(frame)=atan(V(2,1)/V(2,2));
dx(frame)=langd(1)+langd(2);
dy(frame)=langd(3)+langd(4);

end

4
Function that calculates the beam width using the four-sigma method found in ISO
11146. Also the function calculates the offsetlevel.

function ut=andra_moment(infilm)
if nargin == 0
error 'Inga indata. Du mste skicka in en strlfilm s att
funktionen har ngot att arbeta med.';

end
[a,b,c]=size(infilm);

X =zeros(1,c-1);
Y=X;
dx=X;
dy=X;
vinkel=X;
offset=X ;
bildstd=X;
pixlar=X;
offset2=X;
total=X;

for frame=1:c-1
%Ls in aktuell bildruta
profil=infilm(:,:,frame);

%Skapa ett medelvrdes filter och filtrera bilden
h = ones(7,7) / (7*7);
profil2 = imfilter(profil,h,'replicate');

%gr en mask fr de fyra hrnen
mask=zeros(a,b);
da=round(a/20);
db=round(b/20);
mask(1:da,1:db)=1;
mask(a-da:a-1,1:db)=1;
mask(1:da,b-db:b-1)=1;
mask(a-da:a-1,b-db:b-1)=1;

%offset level av vrdet i hrnen
offset(frame)=sum(sum(profil.*mask))/(4*(da*db));

%Plocka ut vrdena i hrnen till en vektor
temp=1;
for y=1:a
for x=1:b
if mask(y,x)==1
varde(temp)=profil(y,x);
temp=temp+1;
end
end
end
%och berkna standardavvikelsen fr vektorn
bildstd(frame)=std(varde);

%Kontrollerar om pixlar r upplysta E(x,y)<E(offset)+n*sigma
mask2=(profil2 < (offset(frame)+3*bildstd(frame)/7));
pixlar(frame)=sum(sum(mask2));
figure(3)%Visa upplysta pixlar som en bild
imshow(mask2)


5
if pixlar(frame)>10
offset2(frame)=sum(sum(profil.*mask2))/pixlar(frame);
else
offset2(frame)=offset(frame);
end

%Kommentera fram nskad metod fr att erhlla offset level
%offset3=offset(frame); %Vrdena i hrnen
%offset3=offset2(frame); %Oupplysta pixlar
offset3=30/256; %Fast vrde

profil=profil-offset3;
total(frame)=sum(sum(profil));

%=============================================
%Tyngdpunkten
y=(1:a)'*ones(1,b);
x=(b-(1:b)'*ones(1,a))';

X(frame) = sum(sum(x.*profil))/total(frame);
Y(frame) = sum(sum(y.*profil))/total(frame);

X2= sum(sum(((x-X(frame)).^2).*profil))/total(frame);
Y2= sum(sum(((y-Y(frame)).^2).*profil))/total(frame);

XY= sum(sum(((x-X(frame)).*(y-Y(frame))).*profil))/total(frame);

g=sign(X2-Y2);

dx(frame)=2*sqrt(2)*sqrt((X2+Y2)+g*sqrt((X2-Y2)^2+4*(XY)^2));
dy(frame)=2*sqrt(2)*sqrt((X2+Y2)-g*sqrt((X2-Y2)^2+4*(XY)^2));

if X2 == Y2
vinkel(frame)=sign(XY)*pi/4;
else
vinkel(frame)=0.5*atan(2*XY/(X2-Y2));
end

end
%Vljer vad som skall retureras frn berkningarna.
ut =dy

6
Appendix C: Equipment
- NdYAG-laser, ~25 W CW SIEMENS Silamatic [D1]
- PC [D2]
- Matlab 7 (Software for calculations) [D3]
- National Instrument
o Labview 7.0 [D4]
o IMAQ Vision (Image processing module) [D5]

- Cameras
o Fujitsu TCZ-200E (B&W CCD field transfer) [D6]
o Philips NC8925 (B&W CCD frame transfer) [D7]
o PULNIX OESI 71533 (B&W CCD field transfer) [D8]
- Web Camera. (color CMOS) [D9]

- Adaptec AVC-2000 (Frame grabber unit) [D10]
- Various laser mirrors [D11]

You might also like