Derechos Reservados © 2011, SOMIM EXPERIMENTAL AND

Anuncio
MEMORIAS DEL XVII CONGRESO INTERNACIONAL ANUAL DE LA SOMIM
21 al 23 DE SEPTIEMBRE, 2011 SAN LUIS POTOSÍ, MÉXICO
A3_59
EXPERIMENTAL AND SIMULATED AIR BENDING STUDY
ASSISTED BY IMAGE RECOGNITION
Contreras Garza David, Hendrichs Troeglen Nicolás, Siller Carrillo Héctor, Flores Valentín Abiud
Centro de Innovación en Diseño y Tecnología (CIDyT), Tecnológico de Monterrey, Campus Monterrey;
E. Garza Sada 2501 Sur; 64849, Monterrey, N.L.; México.
Teléfono (81) 8358 1400 ext 5324
[email protected], [email protected], [email protected], [email protected]
RESUMEN
much faster than
measurement methods.
Los Aceros Avanzados de Alta Resistencia
(AHSS por sus siglas en inglés) están siendo
utilizados en la industria por su resistencia y
bajo peso, pero predecir correctamente su
geometría final después del formado todavía
requiere más estudio. Por una parte, el doblado
al aire genera, por naturaleza, una geometría
no-perfecta que es difícil de determinar, por lo
que se requiere de formas alternativas de
medición.
El software de reconocimiento de imágenes es
ampliamente utilizado para aplicaciones
biomédicas y biométricas, y ha demostrado
medir y caracterizar los diferentes aspectos de
una imagen de forma automática y confiable.
La metodología propuesta en este estudio, aplica
para predecir la geometría final de AHSS
doblados al aire. El proceso fue asistido por un
algoritmo de reconocimiento de imagen para
detectar la geometría experimental de forma
automática y mucho más rápida que los métodos
de medición convencionales.
ABSTRACT
Advanced High Strength Steels (AHSS) are
being used in industry for their strength and low
weight, but correctly predicting their final
geometry after forming still requires further
study. Moreover, air bending generates a nonperfect geometry by nature which is difficult to
determine, so there is a need for alternate ways
of measurement.
Image recognition software is widely used for
biomedical and biometrics applications and has
proven to measure and characterize different
aspects of an image automatically and in a
reliable way.
The proposed methodology of this study, used to
predict the final geometry of AHSS after air
bending. The process was assisted by an image
recognition algorithm so that the experimental
geometry could be detected automatically and
ISBN: 978-607-95309-5-2
current
conventional
INTRODUCTION
The primary reason behind the use of AHSS in
automobiles is the reduction of fuel consumption
and the safety of occupants (Koppel Conway,
2009). Furthermore, due to their higher strength,
manufacturers hope to reduce their manufacturing costs. Due to their superior mechanical
properties, crashworthiness and mass avoidance
there has been an increase in demands for AHSS
in the automotive industries (Hudgins, 2010).
However because of their low formability their
implementation has been achieved only in some
vital parts in the automobile where a difference
in crash test performance really has paid off
(Koppel Conway, 2009).
Spring-back deformation has becomes a critical
problem when processing AHSS (Keeler, 1994).
Industry has a specific need to predict it correctly
to overcome manufacturing difficulties and one
way to study these phenomena is the air bending
test (ABT).
RELATED WORK
Many experimental and analytical developments
for the ABT have been reported; so for digital
image recognition applied to many different
fields. However, the best integration of these
two areas was done in Girona, Spain back in
2005 (García-Romeu, 2005). García-Romeu’s
work surveyed the state of the art in spring-back
prediction and developed an algorithm for the
detection of curvature and angle of ABT
samples.
Sheet Metal Bending
Different methods are commonly used for sheet
bending (shown in Figure 1), such as folding (a),
air bending (b), rotary bending (c), and flange
bending (d) (Marciniak, 2002). Each of these
Derechos Reservados © 2011, SOMIM
<< pag. 691 >>
A3_59
MEMORIAS DEL XVII CONGRESO INTERNACIONAL ANUAL DE LA SOMIM
21 al 23 DE SEPTIEMBRE, 2011 SAN LUIS POTOSÍ, MÉXICO
processes features different characteristics in the
final product like; curve profile, residual stress,
thickness and geometry (Kalpakjian, 2003).
Figure 1. Different process of bending sheet-metal:
(a) folding, (b) air bending, (c) rotary bending
and (d) flange bending (Marciniak, 2002).
From the different methods to achieve the
desired bend one of the oldest methods is air
bend, which does not require a specific bottom
die for each bending angle, as opposed to “V”
die bending which bottoms on a specific
geometry to assure bend radius and bend angle.
Nonetheless, air bending is regaining relevance
in small lot production because of its speed and
low cost. However, air banding it requires a
deep understanding of the phenomena occurring
in the material to achieve the desired final angle
and radius.
The geometry obtained from air bending is not a
perfect segment of a circle, even though the
punch may be so. The sheet metal is normally
flexed over the unsupported length as shown in
Figure 2.
Image Recognition
After each bend the desired final geometry, after
spring-back, is a part with defined bend angle
and bend radius. The assumption is a circular
profile in the bend (Kalpakjian, 2003). This is
not normally the case for air bend; however, the
best fit circle and the best fit angle are normally
used to describe such geometries (Diegel, 2002),
(Precision Metalforming Association, 2004).
ISBN: 978-607-95309-5-2
Figure 2. In air bending, the sheet metal curve is
different to the punch radius and extends beyond the
punch.
Image recognition is widely used in biometric
and biomedical applications, thus there are some
implemented algorithms that recognize measure
and modify certain aspects of an image. Thus,
the idea is to use this technique to measure air
bend samples as already shown by GarcíaRomeu (García-Romeu, 2005).
One of the ways to acquire a good quality digital
image for the recognition software is a digital
camera (Lin, 2010). The image can later be
treated to acquire the desired characteristics of
contrast that will be transformed to numbers in a
matrix, either in a black and white image or a
gray scale.
According to (García-Romeu, 2005), to obtain a
digital image of an object, with enough contrast
to be detected by image recognition software, a
white paint coat on the face to be analyzed will
suffice. For maximum contrast, a black opaque
surface in the background is adequate.
Derechos Reservados © 2011, SOMIM
<< pag. 692 >>
MEMORIAS
S DEL XVII CON
NGRESO INTERN
NACIONAL ANUA
AL DE LA SOMIM
21 al 23 DE
E SEPTIEMBRE, 2011 SAN LUIS POTOSÍ, MÉXIC
CO
A3_59
Binaryy images are reecommended for
f morphologyy
detectiion (Russ, 199
95). In this waay backgroundd
characcteristics are seeparated complletely from thee
objectt characteristics. It is also needed
n
to cleann
the im
mage from defeects like dust or
o cracks. Forr
this, a number of diffferent filteringg methods thatt
add, subtract or elim
minate fractionns of the imagee
matically can bee used (Gonzáleez, 2009).
autom
n image is obtaained it can bee
Once a B&W, clean
processsed by mean
ns of any proven generall
methoodology (Rezaa Fallahi, 20010).
Thesee
methoodologies use image
i
characteeristics such ass
a conttrast ratio, colo
or gamut or genneral pixel (px))
size. Then, a speciffic area of thee image can bee
selecteed for analysiis, be it featuure extraction,
measuurement or classification (see
(
MatLab®
code inn Appendix A)).
Figure 4. Air bending tool withh test sample.
Imagee Thinning
Once a single, hig
gh contrast white
w
image iss
ware can anaalyze differentt
achievved the softw
aspectts of it. In the case of bend samplee
measuurements (anglle and radius)) the softwaree
makess the image so thin as to retaiin only 1 px off
the feaature of interesst.
sp
Figure 5. Test sample before spring-back.
Figure 6. Tesst sample after sppring-back.
Figurre 3. Example of a black & whitte filtering and
thinnning steps for finger-vein
fi
imagee recognition
(Cheeng-Bo, 2009).
achieeved (Figure 5) and the seecond one afteer
remooving the load (Figure 6). Puunches available
for the
t bending toool had radiuuses of 7.5 mm
m,
12.0 mm, 15.0 mm and 22.5 mm respectively.
r
p
is know
wn as thinning and is used too
This process
characcterize general geometry as if it were thinn
branchhes representaative of the feature to bee
characcterized (examp
ple in Figure 3).
3
w
taken from
m a 3 mm thicck
The test sample were
d
nam
mely 0°, 45° annd
DP6000 sheet in 3 direction,
90° with
w respect to the rolling direection.
ULATION
SIMU
ERIMENT
EXPE
e
carrried out was a typical air-The experiment
bendinng test similarr to a 3 pointt bending test.
The experimental
e
to
ool (shown inn Figure 4) iss
capablle of performiing stretch bennd test and airr
bend tests and waas setup in a tension testt
w painted inn
machine. The testt specimen was
a an opaquee black surfacee
white on one side and
m
to gett
was atttached to the back of the machine
the beest possible co
ontrast on the digital
d
images.
Two pictures
p
were taken during the test. Thee
first one
o
was takeen after the desired
d
punchh
penetrration was
ISBN: 978-607-95309-5-2
mulations werre
Air bend Test (ABT) sim
perfoormed with DEFORM 3D®, a softwarre
especcial developeed for simulating forminng
operaations involvinng large displacements. Thhe
simuulation setup, shown in Figgure 7, was a
simplified version of the holdiing tool. Thhe
contrrol variable of the simulationn was the puncch
strokke measured during
d
the phhysical bendinng
tests so as to achieve simillitude of botth
s
didd not require anny
experriments. The simulation
speciial boundary conditions because
b
in air
a
bendding the work piece
p
has to slipp into the die.
Derrechos Reserrvados © 2011, SOMIM
M
<< pag. 693 >>
MEMORIAS DEL XVII CONGRESO INTERNACIONAL ANUAL DE LA SOMIM
21 al 23 DE SEPTIEMBRE, 2011 SAN LUIS POTOSÍ, MÉXICO
A3_59
IMAGE RECOGNITION ALGORITHM
A convergence analysis of the algorithm was
performed to test if and when the process
stabilized, and to know how many pixels were
needed to get a satisfactory outcome. As an
example, for an expected radius of 1, it was
observed that the most important indicator was
the amount of pixels in the bent zone, as
observed in Figure 11 and Figure 12. Results
show that from 200 px on the results are stable.
Figure 7. Geometry for simulation.
Measured Radius
To optimize the mesh, only the contact zone with
the punch had a much denser mesh than the rest
of the work piece (finer by a factor of 3), as
shown in Figure 8. This approach helped to
reduce the processing time of each simulation.
Sensitivity analysis was made by testing a
different number of elements for the meshes in
one scenario. For this simple geometry a number
of elements around 1,000 were proven to be
adequate. Smaller number of elements generated
inconsistent results and even unsolvable systems.
Meshes above 1,000 elements had stable results
but the solution time did increase significantly.
1.4
1.2
1.0
0.8
0.6
0
200
400
600
800
1,000
1,200
Pixeles in Bending Zone
Measured Angle
Figure 11. Radius measurement convergence
stabilizes after 200px in the bending zone.
92
91
90
89
88
0
200
400
600
800
1,000
1,200
Pixeles in Bending Zone
Figure 12. Angle measurement stabilizes
after 200px in the bending zone.
The material characteristics were taken from
Corona’s work (Corona, 2010), as he
characterized the anisotropic properties of a
3 mm thick AHSS DP600 sheet. Anisotropy was
defined with Hill’s quadratic approach (Figure 9)
and flow stress as a curve (Figure 10).
This analysis was performed to limit the size of
the image for a faster processing with good and
stable results. If the size of the image is too large
the time taken to process it increases
exponentially as shown in Figure 13.
Computing Time
Figure 8. Finer mesh in the bending zone.
1.E+03
103
1.E+02
102
1.E+01
101
1.E+00
100
10‐1
1.E‐01
0
R0 (Rx) 0.970
R45 (Rxy) 0.995
R90 (Ry) 0.995
Strain Rate
1
100
400
0.0 0.1 0.2 0.3 0.4
Strain
Strain
Flow Stress (MPa)
500
Flow Stress (MPa)@ 20° C
Strain Rate
1
100
0.000
0.0
0.0
0.006 399.8 413.6
0.026 479.8 493.6
0.050 536.1 549.9
0.078 572.1 586.4
0.107 600.1 613.9
0.360 619.4 633.2
Figure 10. Graph for the Flow Stress for DP600
as used in DEFORM 3D®.
ISBN: 978-607-95309-5-2
400
600
800
1,000
1,200
Pixeles in Bending Zone
Figure 13. Time taken by the algorithm
to process data compared
to the number of pixels in the image.
Figure 9. Anisotropy index for DP600.
600
200
These tests were performed on an ideal geometry
designed in Solid Edge®. The piece was exactly
1mm thick, 1mm internal radius and a bend
angle of 90º. The algorithm approximated the
geometry as shown in Figure 14. The black thin
line represents the algorithm output and a thicker
color line represents the idealized input image.
For this ideal test the error was 0.001% for the
angle and 1.53% for the radius.
Derechos Reservados © 2011, SOMIM
<< pag. 694 >>
MEMORIAS DEL XVII CONGRESO INTERNACIONAL ANUAL DE LA SOMIM
21 al 23 DE SEPTIEMBRE, 2011 SAN LUIS POTOSÍ, MÉXICO
A3_59
2,200
Angle=89.9989°
Int. Radius=0.9847 mm
2,000
200
Exp 0‐7.5
Exp 0‐12
Exp 0‐15
Exp 0‐22.5
Exp 45‐7.5
Exp 45‐12
Exp 45‐15
Exp 45‐22.5
Exp 90‐7.5
Exp 90‐12
Exp 90‐15
Exp 90‐22.5
1,800
1,600
Bending Force [N]
150
100
50
1,400
1,200
1,000
800
600
0
400
200
‐50
‐150
‐100
‐50
0
50
100
0
150
0
Figure 14. Internal and external radius (color)
compared with the non linear regression (black).
Table 1 and Table 2. These results were
compared to physical measurement of the
samples taken on a coordinate measuring
machine. The measurements were done by
taking 4 points in the bending zone and 3 points
on the straight lines.
Table 1. Comparison of the physical vs. algorithm
measurements on the radius of test samples.
Bend Radius
Thickness Physical
(mm)
(mm)
1.20
10.53
2.15
6.57
4.68
7.65
7.89
29.85
Algorithm
(mm)
9.85
6.08
8.03
30.57
40
50
Figure 15. Force vs. displacement
for all Air Bend Test experiments.
The simulation software (DEFORM 3D®)
rendered the same forces and displacements
output, which is in good agreement with the
experimental evidence (Figure 16).
2,200
2,000
Sim 0‐7.5
Sim 45‐7.5
Sim 90‐7.5
Sim 0‐12
Sim 45‐12
Sim 90‐12
Sim 0‐15
Sim45‐15
Sim 90‐15
Sim 0‐22.5
Sim 45‐22.5
Sim 90‐22.5
1,800
1,600
1,400
1,200
1,000
800
Algorithm
(deg)
119.43
104.40
120.32
89.74
400
Error
(%)
6.45
6.53
4.95
2.42
Error
(%)
0.09
1.66
0.34
0.04
RESULTS
Force and displacement for each DP600 sample
was measured on the tension test machine.
Figure 15 is a summary of the data acquired
during the experiment; sample ID includes
orientation with respect to the rolling direction
and punch radius.
ISBN: 978-607-95309-5-2
30
600
Table 2. Comparison of the physical vs. algorithm
measurements on the bend angle of test samples.
Bend Angle
Thickness Physical
(mm)
(deg)
1.20
119.54
2.15
102.69
4.68
119.91
7.89
89.77
20
Displacement [mm]
Bending Force [N]
The algorithm was also tested with images from
arbitrary test samples. The algorithm results for
radius and bend angle are shown in
10
200
0
0
10
20
30
40
50
Displacement [mm]
Figure 16. Force vs. displacement
for all Air Bend Test simulations.
The experiments and the simulation are in good
agreement; as the displacement-force results
compare rather good for all different punch
radiuses (Figure 17, 18, 19 and 20).
Furthermore, to compare the physical results
with the simulations, pictures were taken from
the DEFORM 3D® displays and analyzed with
the image recognition algorithm; both before and
after spring-back.
When comparing the measurements of radius
(Figure 21 and Figure 22) it can be seen that
there is an area of opportunity in the simulations
prediction; in all cases the simulated radius is
30%, or more, smaller than the corresponding
experimental value.
Derechos Reservados © 2011, SOMIM
<< pag. 695 >>
MEMORIAS DEL XVII CONGRESO INTERNACIONAL ANUAL DE LA SOMIM
21 al 23 DE SEPTIEMBRE, 2011 SAN LUIS POTOSÍ, MÉXICO
1,800
1,800
1,600
1,600
1,400
1,400
Bending Force [N]
Bending Force [N]
A3_59
1,200
1,000
800
600
400
1,200
1,000
800
600
400
Sim 0
200
Sim 45
Sim 90
Exp 0
Exp 45
Exp 90
Sim 0
200
0
Sim 45
Sim 90
20
30
0
10
20
30
40
50
60
0
10
Displacement [mm]
Exp 45
Exp 90
40
50
60
Displacement [mm]
Figure 17. Experimental vs. Simulation Displacement
- Force Plot for the 7.5 mm radius punch.
Figure 19. Experimental vs. Simulation Displacement
- Force Plot for the 15.0 mm radius punch.
1,800
1,800
1,600
1,600
1,400
1,400
1,200
Bending Force [N]
Bending Force [N]
Exp 0
0
1,000
800
600
400
1,200
1,000
800
600
400
Exp 0
200
Exp 45
Exp 90
Sim 0
Sim 45
Sim 90
Sim 0
200
0
Sim 45
Sim 90
Exp 0
Exp 45
Exp 90
0
0
10
20
30
40
50
60
0
Displacement [mm]
20
30
40
50
60
Displacement [mm]
Figure 18. Experimental vs. Simulation Displacement
- Force Plot for the 12.0 mm radius punch.
Figure 23 summarizes the initial bend angle
results. A small difference between the angles
measured from the 3D simulations and the
experimental measurements with the image
recognition software can be seen.
However, there is a noticeably bigger
discrepancy
between
the
final
angle
measurements, as shown in Figure 24; which
compares the experiments, the simulations and
the CMM values. These later compare well to
the experiments, but differ greatly from the
simulations.
CONCLUSIONS
It is common practice to use force and
displacement values con “calibrate” simulation
results (Hudgins, 2010; Corona, 2010; González
Ángel, 2010). The present study indicates that
for bending, were spring-back is very noticeable,
this procedure may lead to false assumptions.
ISBN: 978-607-95309-5-2
10
Figure 20. Experimental vs. Simulation Displacement
- Force Plot for the 22.5 mm radius punch.
The data acquired from the tensile testing
machine during the air bending experiments is in
very good agreement with the estimates from the
3D simulations (Figure 17, Figure 18, Figure 19
and Figure 20). However, when working with
final geometry considerations, mayor differences
may arise due to a lack of precision of the
constitutive model used in the simulating
environment. As seen in Figures 21, 22, 23 and
24, the differences between experimental and
simulation results can be significant. Further
experimentation and simulation should be carried
out to improve the estimation precition.
However, rapid measurement methods such as
the one developed here, that allow comparing
physical experimentation results to simulation
results via image recognition software, seems
appropriate for such further research.
The implementation of image recognition
software may also be useful for other kinds of
deformation processes as long as they are visible,
Derechos Reservados © 2011, SOMIM
<< pag. 696 >>
MEMORIAS DEL XVII CONGRESO INTERNACIONAL ANUAL DE LA SOMIM
21 al 23 DE SEPTIEMBRE, 2011 SAN LUIS POTOSÍ, MÉXICO
A3_59
90‐22.5
90‐22.5
90‐15.0
90‐15.0
90‐12.0
90‐12.0
90‐7.5
90‐7.5
45‐22.5
45‐22.5
45‐15.0
45‐15.0
45‐12.0
45‐12.0
45‐7.5
45‐7.5
0‐22.5
0‐22.5
0‐15.0
0‐15.0
0‐12.0
0‐12.0
0‐7.5
0‐7.5
0
5
10
15
20
25
30
35
0
40
10
20
30
40
Experiment
50
60
70
80
90
100
110
120
Initial Angle (deg)
Initial Radius [mm]
Experiment
Simulation
Figure 21. Initial radius measurements of all test
samples (before spring-back).
Simulation
Figure 23. Initial bend angle measurements of all test
samples (before spring-back).
90‐22.5
90‐22.5
90‐15.0
90‐15.0
90‐12.0
90‐12.0
90‐7.5
90‐7.5
45‐22.5
45‐22.5
45‐15.0
45‐15.0
45‐12.0
45‐12.0
45‐7.5
45‐7.5
0‐22.5
0‐22.5
0‐15.0
0‐15.0
0‐12.0
0‐12.0
0‐7.5
0‐7.5
0
5
10
15
20
25
30
35
0
10
20
30
Final Radius [mm]
CMM
Experiment
50
60
70
80
90
100
110
120
Final Angle (deg)
Simulation
CMM
Experiment
Simulation
Figure 24. Final bend angle measurements of the test
samples (after spring-back).
Figure 22. Final radius measurements of all test
samples (after spring-back).
and there is a clear and orthogonal line of sight.
Potentially, the software could be automated for
different visual experiments and the code could
also be tailored to interpret video so that it could
assist the analysis of each step of any
deformation process. Furthermore, it could be
integrated into the hardware and software of
specialized machines for real time control
functions.
Although CMMs are very accurate, said
accuracy depends on the points taken by the
technician which are only a few (typically less
than 10). The algorithm here developed can help
eliminating the need for these highly qualified
and experienced technicians for CMM
measurements, as it does not depend on the
zones chosen to acquire the data. The algorithm
simply measures the whole curve based on tens
or even hundreds of points.
At the present stage of development, the software
still requires a fair amount of user input to
preprocess the images (generate enough contrast)
and to find the circles and lines within the overall
geometry.
ISBN: 978-607-95309-5-2
40
However, as the algorithms get more elaborate
and find their way into more sophisticated
applications, they also will become faster, selfsufficient and more precise.
REFERENCES
1) Cheng-Bo, Y. (2009). Finger-vein image
recognition combining modified hausdorff
distance with minutiae feature matching. J.
Biomedical Science and Engineering , 261272.
2) Corona, J. G. (2010). Modelado de la carga
aplicada a materiales anisotrópicos en el
proceso de doblado-estirado. Monterrey,
México: ITESM.
3) Diegel, O. (2002). BendWorks: the fine art of
sheet metal bending. Complete Design
Services.
4) García-Romeu, M. L. (2005). Contribución
al estudio del proceso de doblado al aire de
chapa. Modelo de predicción del ángulo de
recuperación y de radio de doblado final.
Girona: Università de Girona.
Derechos Reservados © 2011, SOMIM
<< pag. 697 >>
A3_59
MEMORIAS DEL XVII CONGRESO INTERNACIONAL ANUAL DE LA SOMIM
21 al 23 DE SEPTIEMBRE, 2011 SAN LUIS POTOSÍ, MÉXICO
5) González Á., Rodriguez C., Hendrichs N.,
Elías A., Sillr H. (2010). Finite element
analysis of stretch-bending for advanced high
strength steels. XVI Congreso Internacional
Anual de la Sociedad Mexicana de Ingeniería
Mecánica. Monterrey, México: SOMIM.
6) González, R. C. (2009). Digital Image
Processing using MATLAB. Gatesmark
Publishing.
7) Hudgins, A. (2010). Predicting instability at
die radii in advanced high strength steels. J.
Materials Processing Technology , 210 (5),
741-750.
8) Kalpakjian, S. (2003). Manufacturing
Processes for Engineering Materials. NJ:
Pearson Education.
9) Keeler, S. P. (1994). Application and
Forming of higher strength steel. J. Materials
Processing Technology , 46 (3-4), 443-454.
10) Koppel Conway, A. (08 de 2009). Advanced
High Strength Steel. Recuperado en
Novembre de 2010, de Collision Standard:
http://www.collisionstandard.com/
11) Lin, J.-J. (2010). Pattern Recognition of
Fabric Defects Using Case-Based Reasoning.
Textile Research Journal .
12) Marciniak, Z. (2002). Mechanics of Sheet
Metal Forming. Oxord: ButterworthHeinemann.
13) PMA. (2004). Design Guidelines for Metal
Stamping and Fabrication. Independance,
OH: Precision Metalforming Association.
14) Reza Fallahi, A. (2010). A new approach for
classification of human brain CT images
based on morphological operations. J.
Biomedical Science and Engineering , 78-82.
15) Russ, J. (1995). The image processing
handbook. Boca Raton: CRC Press.
Appendix A: MathLab® code for Image
Recognition
The code included reads a group of preprocessed
images (with sufficient contrast) and generates
the bend angle and the bend radius for each of
them.
clear,clc
muestra=['A22.jpg'];
%list of test files ['sample1.jpg';'sample2.jpg']
[tam n]=size(muestra);
espesor=[3.01]; %sheet metal thickness [2;3]
ISBN: 978-607-95309-5-2
for k=1:tam %for a sample size tam
tic%to take time t1
root=imread(muestra(k,:));%gets k-th image
t=espesor(k,:);%gets k-th thickness
mod=limpiar(root);%calls a subroutine to get a
binary image and clean defects
limwidth=800; %limits the image width
[trash x_mod]=size(mod);
if (x_mod >= limwidth)
mod=imresize(mod,limwidth/x_mod);
root=imresize(root,limwidth/x_mod);
end;
clear x_mod
mod=aislar(mod);%gets only the biggest area
t_pv=sum(mod(:,1));%gets
the
vertical
thickness in pixels
mod=media(mod);%gets the mid sufrace
mod=borde(mod,t_pv);%crops image
t1=toc; %takes time t1
figure(1);[trash c]=imcrop(mod);%asks the
user to put the curve in a box
tic %takes time t2
clear trash
close Figure 1
c=round(c);
mod(c(2):c(2)+c(4),c(1):c(1)+c(3))=0;%removes
a square section
[L Ne]=bwlabel(mod);
clear mod
prop=regionprops(L,'Orientation');%gets the
angle of both straight lines
angs=sort([prop(1).Orientation
prop(2).Orientation]);
ang=180+angs(1)-angs(2);%gets the bend
angle
t_p=t_pv*cos(abs(angs(1))*pi/180);%converts
vertical pixels to thickness pixels
pix2mm=t/t_p;
%makes the image more symetric
rot=-(angs(2)+angs(1))/2;
mod=imrotate(root,rot,'bilinear');
angs=angs+rot;
mod=limpiar(mod);
mod=aislar(mod);
mod=mincrop(mod);
mod=borde(mod,t_p);
root=mod;
%Non linear regresion for internal radius
mod=sup(mod);%gets the top border
mod=doblez(mod,angs,t_p);
mod=aislar(mod);
npi=nnz(mod);
[rpi,Yi,Xi]=regresion(mod);%makes a non
linear regression for a circle
Derechos Reservados © 2011, SOMIM
<< pag. 698 >>
A3_59
MEMORIAS DEL XVII CONGRESO INTERNACIONAL ANUAL DE LA SOMIM
21 al 23 DE SEPTIEMBRE, 2011 SAN LUIS POTOSÍ, MÉXICO
rpi=rpi-0.5;
%Non linear regresion for exterior radius
mod=root;
mod=sub(mod);%gets the bottom border
mod=doblez(mod,angs,t_p);
mod=aislar(mod);
npe=nnz(mod);
[rpe,Ye,Xe]=regresion(mod);%makes a non
linear regression for a circle
rpe=rpe+0.5;
npt=npe+npi;
r_p=(rpe-t_p)*npe/npt+rpi*npi/npt;
r=r_p*pix2mm;
t2=toc;
tiempo(k)=t1+t2;%gets the time for the k-th
iteration
radio(k)=r;
angulo(k)=ang;
npix(k)=npi+npe;
figure(2)%shows results
m=ceil(sqrt(tam));
subplot(m,m,k),
plot(Xi,Yi+t_p,'.r',Xe,Ye,'.g');
hold on
plot(Xi,rad(rpi,Xi)+t_p,'-b',Xe,rad(rpe,Xe),'b');
title({muestra(k,:);['Angº=
'
num2str(ang)];['Rad int= ' num2str(r,4)]});
axis equal;
hold off
end
function [img]=aislar(img)
%This functions isolates the biggest white area
in a BW image
L=bwlabel(img);
propied=regionprops(L,'Area','BoundingBox');
Amax=max([propied.Area]);
s=find([propied.Area]<Amax);
for n=1:size(s,2)
d=round(propied(s(n)).BoundingBox);
img(d(2):d(2)+d(4),d(1):d(1)+d(3))=0;
end
function [img]=borde(img,t)
%deletes imperfections in the border
[y_img,x_img] = size(img);
img=imcrop(img,[t,0,x_img-2*t,y_img]);
function [img] = doblez(img,angs,t)
%gets only the bending zone
[m,n]=size(img);
ISBN: 978-607-95309-5-2
m1=find(img(:,1)==1);
m2=find(img(:,n)==1);
for x = 1:n%draws two straight lines
rect(m1+round(x*tan(angs(1)*pi/180)),x)=1;
rect(m2+round((nx)*tan(angs(2)*pi/180)),x)=1;
end
B=strel('disk',ceil(t/30));
rect=imdilate(rect,B);
rect=imcrop(rect,[0,0,n,m]);
img=img&not(rect);%boolean operations to
get only the bending zone
img=mincrop(img);
function[img]=limpiar(img)
%This function converts the image to BW
img=rgb2gray(img);
umb=graythresh(img);
img=im2bw(img,umb);
function[img]=media(img)
%Makes a thin line
img=bwmorph(img,'thin',Inf);
function [img]=mincrop(img)
%removes border imperfections
c=minrect(img);
img=imcrop(img,c);
function [c]=minrect(img)
%get’s the minimum coordinates for the image
[m,n]=find(img==1);
c=[min(n),min(m),range(n),range(m)];
function [y] = rad(r,x)
%Function for the circle for the lower quadrants
y=r-sqrt(r.^2-x.^2);
function [r_p,Y,X] = regresion( img )
%Gets the non linear regression for a circle
[Y X]=find(img==1);%get's the XY coordinates
Y=-Y;Y=Y-min(Y);%adjusts the Y values to
start in 0
X=X-mean(X(find(Y==0)));%centers the X
values
[r0,n]=size(X);
r_p=nlinfit(X,Y,@rad,r0);%makes the non linear
regression
function[img]=sub(img)
%Gets the bottom border
B=[0,1,0;
0,1,0;
0,-1,0];
img=bwhitmiss(img,B);
Derechos Reservados © 2011, SOMIM
<< pag. 699 >>
Descargar