Anda di halaman 1dari 28

Semester Thesis

Finite Element Simulation of Soft


Actuators
Charilaos Mylonas

Zoltan Nagy, Dino Rossi


Adviser

Prof. Dr. Arno Schl


uter
Architecture and Sustainable Building Technologies
Swiss Federal Institute of Technology Zurich (ETH)

2013

Dedicated to Alexandra.

Preface

ii

Preface
First of all, I would like to thank Zoltan Nagy and Dino Rossi for the close
supervision of the present work and all the constructive comments during the
design and execution phase of the experiments. Their experience shed much light
on identifying dead-end approaches fast and making this work possible.
I would like to thank my parents for their support and their motivation.
Finally it would be a severe omission not to mention my topographer friends
Maria Kourouni and Harry Lanaras for pointing me to the right direction in order
to apply an approach (that was not included in the present work) in the computer
vision part that provided insights for future works on computer vision techniques
for mechanical experiments.

Abstract

iii

Abstract
Mathematical description of the movement and mechanical behavior of soft robots
is generally analytically intractable. Not only the body of the robot experiences
large distortions, but also the materials typically used for construction are hyperelastic and respond non-linearly to loading. Thus, numerical simulations together
with acurate material description and experimental model parameter determination are playing a considerable role in the evolution of soft actuators.
The present semester project consists of two parts. In the first part the
material parameters are extracted for the material used in the SUAT lab by fitting
Finite Element simulation data to experimental data, acquired by image analysis
techniques. In the second part an actuator designed in the lab is simulated in
order to gain insights for new designs.

Contents

iv

Contents
Abstract
List of Figures

iii
v

1 Introduction

2 Experimental Protocol
2.1 Concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2 Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3 Image Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2
2
2
4

3 Hyperelastic Materials

4 Simulation
4.1 Simulation of the disk-like actuator . . . . . . . . . . . . . . . . .
4.2 Simulation of the seminar actuator . . . . . . . . . . . . . . . . .

7
8
10

5 Summary and Contributions


5.1 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

15
15

References

16

Appendix

16

A Appendix
A.1 Strain and Stress Measures for Hyperelasticity . . . . . . . . . . .
A.2 Image Processing Matlab Code . . . . . . . . . . . . . . . . . . .

17
17
19

List of Figures

List of Figures
1
2
3
4
5
6
7
8
9
10
11

Experimental Setup . . . . . . . . . . . . . . . . . . . .
Image Analysis Procedure . . . . . . . . . . . . . . . .
Experimentally Acquired Surface Deformation . . . . .
Finite Element Mesh . . . . . . . . . . . . . . . . . . .
Finite Element Result - Disk actuator . . . . . . . . . .
Maximum Displacement and Pressure of disk actuator
Surface Deformation - experiment and simulation . . .
pressure 0cm . . . . . . . . . . . . . . . . . . . . . . .
pressure 70cm . . . . . . . . . . . . . . . . . . . . . . .
pressure 130cm . . . . . . . . . . . . . . . . . . . . . .
pressure 177cm . . . . . . . . . . . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

3
5
7
8
9
10
11
12
13
13
14

1 Introduction

Introduction

Soft actuator technology has the purpose of creating robots that are more agile
than conventional ones and depend less on electrical power to produce motion.
In addition soft actuators are monolithic structures where the motion creating
mechanism is indistinguishable from the rest of the structure. Soft robots are
considerably simpler faster and cheaper to fabricate, and can be constructed out
of biodegradable materials that have a small ecological footprint.
Instead of relying on bulky electrical mechanisms to produce motion or interact with their environment the actuators investigated in this study rely on
pressure variation to produce motion. Soft actuators are constructed with materials that express high deformations and generally have a non-linear stress-strain
behavior. Due to the non-linearity of their behavior, soft materials call for special
experimental methods in order to acquire their model parameters. In the present
study the main focus is the design of a material characterization method that
relies on image analysis techniques and numerical simulation. The main advantage of the technique described in the present study over others is simplicity and
reproducibility with readily available materials and common tools. The project
concludes with a simulation of an existing structure used in an architectural
project.

2 Experimental Protocol

2
2.1

Experimental Protocol
Concept

An hollow disk actuator was used for the material characterization process.
Hyperelastic materials express high deformations for relatively low loading.
Thus the a priori assumed relatively limited accuracy of an image analysis technique was not considered to be a problem for relatively accurate material characterization.
Since the actuator to be studied possessed a centrally symmetric geometry,
and sensing the displacements of the membrane would interfere with the measurements it was considered a valid procedure to infer the shape of the surface
by a non-invasive shadow casting technique.
Initially considerable attempts were made for the surface extraction to be done
with the structure from motion technique using images acquired from 2 different
cameras during the experiment. Unfortunately this method did not work well
because it was difficult to control the point correspondence easily and the method
does not express good accuracy when applied only to one pair of photographs.
In addition the smoothness of the actuator surface posed a considerable difficulty
in the automatic detection of SIFT descriptor points. The author would not
recommend the use of structure from motion techique in future attempts for
accurate 3D reconstruction in experimental setups. A calibrated stereoscopy
setup would be much more effective for the purpose of 3D surface reconstruction
but also more difficult to construct.

2.2

Preparation

Four hollow disk actuators were constructed in the lab. The actuators consisted
entirely of Ecoflex 0030 (Smoothon) and had similar geometries. Only one actuator was used for material characterization and was the largest one available. The
reason for that choice was that the accuracy of the experimental setup was not
known beforehand and the larger deflections expected from the largest actuator
were considered beneficial for the accurate acquisition of data.
A bright white LED flashlight that emitted effectively parallel beams of light
was chosen for casting the shadow of the actuator. The actuator was positioned

2.2 Preparation

sideways to the flashlights beam direction and with the radial dimension perpendicular to the projection surface. The flashlight was positioned as far as possible
from the actuator and the actuator was positioned as close as possible to the projection surface and to the center of the flashlights beam. The light beam emitted
from the flashlight is not truly parallel but the effect of scaling in the described
setup is negligible. A more valid procedure for acquiring parallel beams of light
would have been to use a Fresnel lens with the flashlight, or an overhead projector. The actuator support consisted simply of a piece of cardboard. The camera
is acquiring the images in an oblique angle and they have to be corrected for
projective distortion. The shadow projection surface consisted of a regular grid
with known distances in order to facilitate the projective distortion correction.
The grid lines were a shade of gray in order to facilitate the thresholding step
described later in the image analysis part. The pressure range that the actuator
was expected to operate (max around 1kPa) is very low in order to be measured
with an affordable and accurate digital sensor.
Figure 1 shows the actual experimental setup used. The flashlight and the
camera are not visible.

Figure 1: Experimental Setup.


The pressure measurement was performed manually with an analog water
column barometer designed and constructed as part of this project in the lab. Tap
water of known density was inserted in a pair of communicating upright tubes of
1cm diameter. The tube diameter is considered large enough so that it is justified
to neglect surface tension effects in the measurements. The pressure was manually
controlled by a 20ml syringe connected to a T-junction that communicates with

2.3 Image Analysis

the air input of the actuator and one input of the barometer. The other side
of the barometer is free. The relative pressure of the interior of the actuator
is inferred by the difference of water column height between the two barometer
tubes.
The images were acquired with a Cannon D550 with lens EF-S 18-55mm fixed
on a tripod. A remote release trigger was employed in order for the position of
the camera to remain constant throughout the experiment.

2.3

Image Analysis

Related Work
After a brief literature review it was found that image analysis is a widely used
method for the experimental acquisition of deformations of hyperelastic material
structures with the purpose of material characterization.
In [7] uniaxial and bulge test experimental results are used to characterize
a hyperelastic material and analytic relations were used for the fitting of material
parameters. The finite element simulation results seem to deviate considerably
from the experimentally acquired in this publication. This is probably due to the
fact that the largest volume of the material is in a low strain state that is not
sufficiently represented in the nature of the experiments used for material characterization. In [5], the stress field of a specimen is inferred by the correlation of a
speckled pattern imprinted on the surface of the specimen. Very good agreement
is found between simulated model and experiment for a complex structure with
different models for hyperelastic materials. The strain energy density function,
that defines the behavior of hyperelastic materials is chosen of high order, due to
the inability of low order models (as the neo-Hookean, the one used in this study)
to capture strain hardening behavior. However for low strains, the neo-Hookean
material model can adequately capture the behavior of the material. In [3] a
more accurate technique based on the detection of fringe patterns was employed
for the acquisition of the specimen shape.
2.3.1

Image Analysis Procedure

After the pictures were acquired they had to be corrected for lens distortion.
The Gimp lensfun tool was chosen for that matter because it already contained

2.3 Image Analysis

calibration parameters for the used camera and lens so the tedious camera calibration part could be easilly performed. A matlab code was created for trimming
the images, creating a binary image that contained only the shadowed points,
correcting for perspective distortion, find the edge points of the binary image,
and finally filter the points that are over the actuator surface. In picture 2 all
the intermediate processing results are shown.

Figure 2: Image Analysis Procedure: Top left - The image after lens distortion
correction. Top right - The image after projective distortion correction. Bottom
left - the thresholded image, Bottom right - the edge detector result on the
thresholded image.
The thresholding part is done with the application of the Mahalanobis distance for robustness and the filtering of the edge points is done by checking their

3 Hyperelastic Materials

inner product to a manually selected surface that represents the undeformed flat
surface of the actuator. The perspective distortion correction is done using the
relevant image warping matlab tools. A set of known coordinate points are chosen and their position is manually selected in a calibration image. Projective
distortion is not an affine mapping (does not preserve parallel lines) thus it is
necessary in order to extract accurate results to correct for it as accurately as
possible and inference with simple linear interpolation would not have given satisfactory results. In order to select the points, another automated robust and
accurate approach would have been using the Hough transform to detect the
lines of the grid in the projection surface and using the intersection of the detected lines as the known points for projective distortion correction. However the
aforementioned approach for the volume of data that had to be processed and
the expected accuracy improvement of the method was not justified.
In figure 3 an example output of the image analysis procedure is shown.
The estimated edge points were in addition smoothed with loess non parametric
regression in order for the procedure not to be sensitive to false edge points. The
smoothed out version of the extracted silhouette of the actuator was fluctuating at
worst in a neighborhood of 5 pixels around a line that naturally followed the shape
of the shadow due to the high resolution of the camera. One pixel correspons to
105 m = 10m . Thus an estimation of the error for the estimated deflection
of the surface, based only on the edge detection step would be around 50m.
By paying attention to the details of thresholding, the contrast of the shadowed
region and the sharpness of the shadow which heavily relies on the quality of
the flashlight the accuracy of the presented method can be greatly improved.
More accurate error estimates could have been derived on the effect of all the
transformations that are applied to the image and this can be an extension of
the present work.

Hyperelastic Materials

Hyperelastic material models are used to describe the behavior of rubber-like


materials. Elastic behavior means that the structure assumes the shape it initially had after the relaxation of externally imposed stresses. The stress and
strain measures used in mechanics of large deformations are different from the

4 Simulation

Figure 3: Left - The edge detection result. Right - Actuator surface points
inferred from shadow for different pressures- not smoothed. In this run there is
a small negative offset and the initial surface is not captured.
ones used in finite strain elasticity. A brief review of the stress and strain measures is given in the appendix. The constitutive relations that couple stress and
strain of hyperelastic materials are defined by a strain energy potential function.
The strain energy potential function is defined with respect to the invariants of
the deformation tensor. The neo-Hookean material model assumes a potential
function of the form shown in 3.1.
W = C1 (I1 3) + D1 (J 1)2 .

(3.1)

Here C1 = 2 , D1 = 2 , I1 = 1 2 +2 2 +3 2 and J = 1 2 3 . The parameters


are the invariants of the deformation tensor that acts on the material usually
referred to as the principal stretches[6]. The parameters and are the well
known Lames parameters that are used for the simplification of elastic material
behavior in the special case of isotropic materials. The Youngs modulus and the
Poissons ratio define the values of the Lame parameters. The numerical solution
of the problem is finding displacements that minimize that strain energy potential
for the applied loading. This problem is generally non-linear so appropriate
adjustments have to be made for the solver.

Simulation

The simulations were run on a windows PC available at the lab. For the disk-like
actuator that was used for material characterization the geometry was simple

4.1 Simulation of the disk-like actuator

enough to be straightforwardly constructed with Comsol CAD capabilities. The


geometry of the triangular actuator was imported from Rhino and edited to construct the model finally used in the simulation. In both simulations the geometrical symmetries of the problem allowed for a simulation of a smaller geometry
with fewer degrees of freedom without compromises solution accuracy. Generally the simulation was quite time consuming. In order to assure convergence of
the result a parametric solver was used where the incrementing parameter was
naturally the pressure with very low pressure increments.

4.1

Simulation of the disk-like actuator

The axis of cylindrical symmetry, which is also the main displacement direction,
is chosen as the Cartesian coordinate system axis Z. Instead of the whole disc a 45
degree slice was simulated with constrained normal displacements along the sliced
faces and fixed Z displacement at a node in the circumference of the structure
as shown in 4. The pressure is defined as a global parameter in units of cm
of water. The specific density of water was measured and found 0.97gr/ml for
the tap water available in the lab. The loading is defined as a normal force per
unit area perpendicular to the surface normals of the internal boundary elements.
The maximum displacements of the actuator for pressure values that were used in
the experiment were calculated in order to be compared with the experimentally
acquired ones.

Figure 4: The finite element mesh of the 45 degree slice of the actuator.
The simulation was run from MATLAB with the COMSOL server interface in
order to calculate the objective function for different material parameter values
for all the pressure loading steps. Optimization for an objective function that is

4.1 Simulation of the disk-like actuator

defined over different steps of a parametric solver is not possible within COMSOL,
at least in a straightforward manner.

Figure 5: The finite element solution of the disk-like actuator. Strain concentration is evident at the interface of the top membrane with the supporting structure.
A parameter search was performed in order to find the appropriate material
parameters. A more accurate optimization approach was not justified due to the
quality of the experimental pressure measurements. Poissons ratio was found
to have negligible effect on the shape of the loading curve as long as it was over
0.47. The fit of the simulation to the experiment is estimated by the mean square
deviation of the experimental maximum deflections from the simulated. In figure
6 the simulated results after the material characterization are superimposed. It is
evident that the main source of inaccuracy is the manual pressure measurement.
It has to be noted, that there was an air-leak in the experimental setup, at the
air input of the actuator, so a small deviation between the observed pressure and
the true pressure at the time of each photographs was expected. The fact that
for higher pressure values the pressure measurement technique fails is probably
due to the aforementioned reason as the effect of an air-leak is expected to be
worse in higher pressure measurements.
In image 5 we can observe a significant strain concentration on the interface
of the top membrane of the structure with the supporting thick walls. This could
lead to failure or performance degradation due to creeping in structures that are
supposed to have a high life span. By careful fabrication and consequent stress
analysis the design of disk-like hyperelastic actuators could be greatly improved.

4.2 Simulation of the seminar actuator

10

Figure 6: The maximum displacement of the actuator. The red line is the experimental result and the red and green lines (almost indistinguishable) are the
maximum displacements calculated in the simulation.
In image ?? we can observe the experimental and the simulated results for
the displacement of the actuator surface superimposed. It is evident that in
the regions of highest strains the accuracy of the simulation is not satisfactory.
This is due to the fact that ecoflex 0030 expresses strain hardening behavior at
high strains and this behavior is not captured by the simple model used in our
simulation. However, the model used seems to be adequate to capture the overall
behavior of the structure, and this is due to the fact that the largest volume of
the material in the structure is in a low strain state.

4.2

Simulation of the seminar actuator

The shape of the second actuator is more complex. The actuator is formed as a
network of air-channels running through the volume of the hyperelastic slice, and
the channels are enlarged as they reach the actuator boundaries. The structure
of the air channels is only visible in the von Misses stress result for the highest

4.2 Simulation of the seminar actuator

11

Figure 7: The finite element simulation results for the surface position for different
pressure values are superimposed to the experimentally acquired ones.
pressure. Air is pumped in the curved structure at the base of the actuator.
Air tends to expand the channels along their longitudinal and cross-sectional
direction. However, the effect of the longitudinal expansion of the channels seem
to have a larger effect on the overall displacement of the actuator. The motion
perpendicular to the initial surface of the actuator is due to the fact that the
air channels are not centered in the thickness direction of the actuator and the
thinner layer expresses lower resistance to deformation than the thicker one. Of
course the motion of this actuator is analytically tractable only under very rough
assumptions. One could find a rough estimate of the actuator body deformation
by inferring the longitudinal change of the channels and assuming a homogeneous
undeformed top and bottom layers of hyperelastic material that distribute the
induced stresses. That approach would definitely yield some results, but dealing
with hyperelastic materials introduces also the material non-linearity and the
non-linearity of large deformations so a computational approach would still be
needed.
The deformation of the actuator body due to pressure increase inside the

4.2 Simulation of the seminar actuator

12

internal channels seems to cause displacements along all the boundary points of
the structure. Moreover, the pressure displacement relation is also also non-linear,
owing to the ubiquitous non-linearity of the problem at hand.

Figure 8: The undeformed seminar actuator


The actuator requires relatively high pressure values to produce motion. Most
of the material is still in a low stress state thus it is safe to assume that the
neo-Hookean model is sufficient for capturing the behavior of the structure. In
the physical model of the actuator elastic instabilities were observed. These
instabilities could be attributed to the strain hardening behavior that we did not
consider in the present study. The interface between the deforming tubules and
their supporting structure is in a high strain state whereas the middle of the
tubules are in a low strain state. Strain hardening predicts that suddenly the
material on top becomes much more flexible compared to the material on the
sides, thus giving rise to a bubble-like instability. Design intuition, at least in
the opinion of the author, dictates that such instabilities should be avoided and
the soft actuator designer should design against them. A possible remedy would
be an aditional strain limiting layer. The unconventional, sometimes unintuitive,
behavior of hyperelastic structures is a subject that should be carefully taken into
account of. A sufficient body of experiments, simplified analytical formulas, and
accurate simulation coupled with careful material characterization are important
for that matter.

4.2 Simulation of the seminar actuator

Figure 9: pressure 70cm water

Figure 10: pressure 130cm water

13

4.2 Simulation of the seminar actuator

Figure 11: pressure 177cm water

14

5 Summary and Contributions

15

Summary and Contributions

An image analysis technique combined with a simple to reproduce physical experiment have been presented. Parameters for a hyperelastic material model
have been determined for the material produced in the lab through coupling of
experiment and simulation. The simulation framework has been set up in order
to be used in later studies for different geometries. It has been observed that
the Neo-Hookean material model describes the overall behavior of the structure
sufficiently well for the application at hand but also has limitations that have
been pointed out. As it was expected the neo-Hookean material model fails to
sufficiently describe deformation in highly stressed areas.

5.1

Future Work

The mechanical behavior of structures constructed with hyperelastic materials


is by far not easy to grasp intuitively. Simulation and optimization can be a
driving force towards the popularization of soft actuators. Especially in the case
of pneumatic actuators structural optimization for the networks of channels could
be coupled with simulation in order to design structures that distribute stress
evenly or produce a specific motion required from a higher level design decision.
The biggest limitation for that goal to be achieved is probably the inadequacy of
simulation tools and numerical solvers in terms of performance. There seems to be
a realtively small body of research until now regarding simulations in mechanics
of large deformations for non-linear elastic materials. This is probably due to
the relatively limited interest in use of hyperelastic structures as load bearing
mechanisms. However, soft actuators are quite likely to attract interest in that
field.

References

16

References
[1] K. J. Bathe. Finite Element Procedures. Klaus-Jurgen Bathe, Feb. 2007.
[2] G. Booch, J. Rumbaugh, and I. Jacobson. The Unified Modeling Language
User Guide. Addison-Wesley, 1999.
[3] K. Genovese, L. Lamberti, and C. Pappalettere. Mechanical characterization
of hyperelastic materials with fringe projection and optimization techniques.
Optics and Lasers in Engineering, 44(5):423 442, 2006.
[4] J. Hou, R. H. Bonser, and G. Jeronimidis. Developing skin analogues for a
robotic octopus. Journal of Bionic Engineering, 9(3):385 390, 2012.
[5] L. Meunier, G. Chagnon, D. Favier, L. Orgas, and P. Vacher. Mechanical
experimental characterisation and numerical modelling of an unfilled silicone
rubber. Polymer Testing, 27(6):765 777, 2008.
[6] R. W. Ogden. Non-Linear Elastic Deformations. Dover Publications, 1984.
[7] M. Sasso, G. Palmieri, G. Chiappini, and D. Amodio. Characterization of hyperelastic rubber-like materials by biaxial and uniaxial stretching tests based
on optical methods. Polymer Testing, 27(8):995 1004, 2008.

A Appendix

A
A.1

17

Appendix
Strain and Stress Measures for Hyperelasticity

A short summary of the concepts essential to the understanding of the mathematical description of hyperelastic material models is presented. The involved
reader is refered to [6] for a mathematical treatment and [1] for a more practical
perspective focused on the finite element solution of the problem.
In the context of mechanics of large deformations stress and strains have to
be defined in such a way that pure rotations and translations do not cause the
material to be strained. We define the reference configuration as X = Xa Ea and
the deformed configuration as x = xa ea where Ea and ea are the normalized
basis vectors in the reference and deformed configurations respectivelly. An infinitestimal line element in the reference and deformed configuration is dX and
d respectively. The infinitestimal line element in the deformed configuration are
connected to the infinitestimal line element in the reference configuration by the
relation
dx = FdX
(A.1)
where F is the deformation tensor defined as
F = Fab =

xa
.
Xb

(A.2)

Then the Green strain tensor is defined as


1
EG = (FT F I)
2

(A.3)

where I is the identity tensor.


Volume elements in the reference and deformed configuration are defined by
using three line elements in the respective configurations.
dv = det(dx(1) , dx(2) , dx(3) )

(A.4)

dV = det(dX(1) , dx(2) , dX(3) )

(A.5)

The displacement is defined naturally as u = x X. By taking the gradient


of the displacement field with respect to the reference coordinate system we find

A.1 Strain and Stress Measures for Hyperelasticity

18

D = F I. The Green strain tensor is then written as,


1 ua
ub
uc uc
(
+
+
)
2 Xb Xa Xa Xb
1
=
(D + DT + DT D)
2

Eab =

(A.6)

Eab

(A.7)

where Einstein summation is used. Due to the polar decomposition theorem[6],


there exist positive definite matrices symmetric second order tensors U and V
and an orthogonal second orer tensor R such that
F = RU = VR

(A.8)

When R = I we have pure strain and when U = I or V = I we have a pure


rotation. Moreover since R is orthogonal it holds that RT R = I. Now it is evident that the green stress A.3 is independent of rotation of the coordinate system
since FT F = UT RT RU = UT U and depends only on pure strains. The tensors
U and V are called left and right stretch tensors . The eigenvalues of these
tensors are called principal stretches and are representative of the strain state of
the body. Defining the principal directions of strain, u(i) , as the directions that
the set of orthonormal vectors that the strain tensors decompose to, we can write
Uu(i) = i u(i)

(A.9)

VRu(i) = i Ru(i)

(A.10)

Here we see that the eigen-values (principal stretches) of the left and right
stretch tensors are the same. The eigenvectors are connected through the R
tensor of the polar decomposition.

A.2 Image Processing Matlab Code

A.2

Image Processing Matlab Code

%The images were c o r r e c t e d with t h e LensFun p l u g i n on gimp . There were


%a l r e a d y c a l i b r a t i o n p a r a m e t e r s f o r t h e used l e n s and camera ( Cannon EOS
%D550 3555mm l e n s )
f in dC or r ec ti on s = 0 ;
%Here i s t h e path t h e images t h a t have t o be p r o c c e s s e d
pth = ' / media / c h a r i l a o s /My P a s s p o r t /3 d r e c o n s t / shadow 3 / run3 / ' ;
% t h e known c o o r d i n a t e s a r e d e f i n e d manually ( c o u l d do t h a t a u t o m a t i c a l l y
% with a hough t r a n s f o r m f o r a g r i d i t would be f a n c i e r but not much more productive . . . )
%I n t h i s example 6 known p o i n t s a r e c h o s e n . P i x e l t o m e t e r s c o r r e s p o n d e n c e 105
knownCoords = [ 0 1 2 0 1 2 ; 0 0 0 2 2 2 ] ' 9 0 0 ;
%The p i c t u r e f i l e n a m e r a n g e assuming c o n t i n u o u s numbering o f p i c t u r e s .
fnameRange = 5 9 6 5 : 5 9 7 4 ;
%f o r m a t t h e f i l e n a m e t o be r e a d
a = imread ( [ pth , ' IMG ' , i n t 2 s t r ( fnameRange ( 1 ) ) , ' . JPG ' ] ) ;
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%

PREPROCCESSING STEPS :
1 . Trim image i n a r e g i o n where t h e known p o i n t s and t h e shadow o f t h e
a c t u a t o r a r e v i s i b l e . The bounds o f t h i s r e g i o n s h o u l d be a v a i l a b l e t o
p r o c e s s a l l t h e images . ( bounds b1 , b2 )
2 . D e f i n e t h e known p o i n t s f o r p r o j e c t i v e d i s t o r t i o n c o r r e c t i o n .
The t r a n s f o r m o b j e c t ( t f o r m ) i s t h e o n l y t h i n g needed from t h i s f u n c t i o n .
3 . Correct f o r the p r o j e c t i v e d i s t o r t i o n
4 . Trim a g a i n t h e image i n t h e i n t e r e s t i n g r e g i o n w i t h o u t t h e b l a c k
r e g i o n c r e a t e d due t o t h e c o r r r e c t i o n s t e p b e i n g v i s i b l e
5 . D e f i n e t h e Mahalanobis t h r e s h o l d i n g r e g i o n ( from top l e f t
t o bottom r i g h t ) . Keep t r a c k o f t h e t h r e s h o l d f o r p r o c e s s i n g t h e
s u b s e q u e n t images .

%{
i f f in dC or r ec ti on s == 1
[ atr , b1 , b2 ] = trim ( a ) ;
imshow ( atr ) ;
t i t l e ( ' Trimmed Image : ' ) ;
%pause ( 1 ) ;
s a v e ( ' b1 ' , b1 ) ; s a v e ( ' b2 ' , b2 ) ;
s a v e ( ' a t r ' , atr ) ;

19

A.2 Image Processing Matlab Code

else
%}
l o a d ( [ pth , ' b1 ' ] ) ; l o a d ( [ pth , ' b2 ' ] ) ; l o a d ( [ pth , ' a t r ' ] ) ;
%end
t i t l e ( 'SET KNOWN POINTS ( a known p a r a l e l o g r a m ) ' ) ;
%{
i f f in dC or r ec ti on s == 1
tform = findTransf ( knownCoords ) ;
atr = imtransform ( atr , tform , ' f i l l ' , 1 2 8 ) ;
imshow ( atr ) ;
save ( ' tform ' ) ;
else
%}
l o a d ( [ pth , ' t f o r m . mat ' ] ) ;
%end
t i t l e ( ' Trimmed Image ' ) ;
%Check t h e shadowed r e g i o n f o r m a h a l a n o b i s d i s t a n c e based t h r e s h o l d i n g :
%{
i f f in dC or r ec ti on s == 1
[ binb , shd ] = m a h a l a n o b i s t h r e s h ( atr , 9 0 ) ;
s a v e ( ' binb ' ) ; s a v e ( ' shd ' ) ;
else
%}
l o a d ( [ pth , ' binb . mat ' ] ) ; l o a d ( [ pth , ' shd . mat ' ] ) ;
%end
%s e t z e r o p l a n e :
%Here you s h o u l d c l i c k on t h e two e d g e s o f t h e a p p a r e n t z e r o d e f o r m a t i o n
%p l a n e o f t h e a c t u a t o r ( So I don ' t have t o program i t . . . ) and t h e program
%w i l l f i n d t h e d i s t a n c e o f t h e d e t e c t e d edge p o i n t s from t h a t p l a n e . Of
%c o u r s e a l l o f t h a t a r e i n t h e p r o j e c t e d p l a n e ( camera and shadow p r o j e c t e d . )
t i t l e ( 'SET ZERO PLANE: ' ) ;
%{
i f f in dC or r ec ti on s == 1
V0 = g i n p u t ( 2 ) ;
s a v e ( 'V0 ' )
else
%}
l o a d ( [ pth , 'V0 . mat ' ] )
%end
Vl = V0 ( 2 , : ) V0 ( 1 , : ) ;
Vn = [ Vl ( 2 ) , Vl ( 1 ) ] ;
h o l d off ;
subplot (1 ,2 ,1) ;
imshow ( atr ) ;

20

A.2 Image Processing Matlab Code

subplot (1 ,2 ,2) ;
%p l o t ( xe , ytemp , ' w ' ) ;

%i m w r i t e ( binb , cm , [ pth , a n i m a t i o n F i l e n a m e ] , ' g i f ' , ' Loopcount ' ) ;


%For movie c r e a t i o n :
F ( l e n g t h ( fnameRange ) ) = struct ( ' c d a t a ' , [ ] , ' colormap ' , [ ] ) ;
maxY = [ ] ;
maxPoints = 9 0 0 ;
f o r i=fnameRange
a=imread ( [ pth , ' IMG ' , i n t 2 s t r ( i ) , ' . JPG ' ] ) ;
t i t l e ( ' Transformed Image ' ) ;
atr = a ( b1 , b2 , : ) ;
atr = ( imtransform ( atr , tform , ' f i l l ' , 1 0 0 ) ) ;
binb = mahalApply ( atr , shd , 9 0 ) ;
%i m w r i t e ( binb , [ pth , a n i m a t i o n F i l e n a m e ] , ' g i f ' , ' WriteMode ' , ' append ' ) ;
%ebinbOld = ebinbOld + e b i n b ;
ebinb = edge ( binb ) ;
subplot (1 ,2 ,1)
%ebinbOld+
imshow ( ebinb )
%F( i min ( fnameRange ) +1) = g e t f r a m e ;
%pause ( 1 ) ;
[ x , y ] = f i n d ( ebinb ) ;
dists = [ yV0 ( 2 , 1 ) , xV0 ( 2 , 2 ) ] Vn ' ;
xe = x ( dists >0) ;
ye = y ( dists >0) ;
ys = smooth ( xe , ye , 2 0 , ' r l o e s s ' ) ;
ye=ys ;
[ xe , I ] = s o r t ( xe ) ;
ytemp = ye ;
f o r i = 1 : l e n g t h ( ye )
ytemp ( i ) = ye ( I ( i ) ) ;
end

subplot (1 ,2 ,2) ;
h o l d on ;

21

A.2 Image Processing Matlab Code

p l o t ( xe , ytemp , ' ' ) ;


h o l d off ;
maxY = [ maxY , max( ytemp ) ] ;
%pause ( 0 . 5 )
end

22

Anda mungkin juga menyukai