Atlas Copco Rock Drills AB ÖREBRO Dokument - Document Examensarbete - Hållokalisering Uppgjord tjst, namn, tfn - Prepered dept, name, telephone Kontr - Chk Rev Dokumentnummer - Document number UTSBP Bertil Planeskog, 5423 A 9 Bilagor Bilaga 1 – Findhole.m Bilaga 2 – FL.C Bilaga 1 – FL.H 29 (41)
Atlas Copco Rock Drills AB ÖREBRO Dokument - Document Examensarbete - Hållokalisering Uppgjord tjst, namn, tfn - Prepered dept, name, telephone Kontr - Chk Rev Dokumentnummer - Document number UTSBP Bertil Planeskog, 5423 A BILAGA 1- Findhole.m %function findhole(n,rotation,dist) %Examensarbete Bertil Planeskog - Atlas Copco Rock Drills AB %Elektronikingenjör <strong>Örebro</strong> Universitet HT-01 %Handledare Hans Gustavsson (Atlas Copco), Roger Gustavsson (<strong>Örebro</strong> Universitet) % %----------------------------------------------------------------------- %Hållokalisering %----------------------------------------------------------------------- % %findhole(nr som anger fillnamn 'borrhål(nr).jpg', rotation av bild i grader, avstånd till hål i cm) % %----------------------------------------------------------------------- %FILTRERING AV BILD %----------------------------------------------------------------------- n=19; rotation=0; dist=100; %if nargin =10 filnamn=['borrhål1',n+38,'.jpg']; end if n>=20 filnamn=['borrhål2',n+28,'.jpg']; end if n>=30 filnamn=['borrhål3',n+18,'.jpg']; end if n>=40 filnamn=['borrhål4',n+8,'.jpg']; end I = imread(filnamn); %I=imrotate(I,rotation); I = imcrop(I,[80 30 239 239]); %skära ut den bild som ska användas figure,imshow(I); hold on; I=rgb2gray(I); %konvertering till gråskala %figure,imshow(I); %hold on; I=histeq(I,128); %Histogram equation %figure,imshow(I); %hold on; I = medfilt2(I, [6 6]); %medianfiltrering %figure,imshow(I); %hold on; BW1=im2bw(I,0.032); %konvertering till svartvit %figure,imshow(BW1); %hold on; BW1=dilate(BW1,ones(9)); %svällning av de ickesvarta områden för att minska sprickor mm %figure,imshow(BW1); %hold on; %----------------------------------------------------------------------- %hitta topp %----------------------------------------------------------------------- kol=10; rad=10; hit=0; while (hit == 0) %hitta högsta punkt % plot(kol,rad,'go'); 30 (41) if (BW1(rad,kol)== 0) & (BW1(rad+10,kol) == 0) & (BW1(rad+10,kol-8) == 0) &(BW1(rad+10,kol+8) == 0) break; end kol=kol+5; if kol >= 230 kol = 10; rad=rad+1; if rad>=230 break; end end end koord_top = [rad kol]; %koordinat för den högsta punkten plot(kol,rad,'yo'); %----------------------------------------------------------------------- %hitta vänstra punkt %----------------------------------------------------------------------- kol=10; rad=10; hit=0; while (hit == 0) %hitta vänstra punkt % plot(kol,rad,'go'); if (BW1(rad,kol)== 0) & (BW1(rad,kol+10) == 0) & (BW1(rad+8,kol+10) == 0) & (BW1(rad-8,kol+10) == 0) break; end rad=rad+5; if rad >= 230 rad = 10; kol=kol+1; if kol>=230 break; end end end koord_left = [rad kol]; %koordinat för den vänstra punkten plot(kol,rad,'yo'); %----------------------------------------------------------------------- %hitta botten %----------------------------------------------------------------------- kol=10; rad=230; hit=0; while hit==0 %hitta nedersta punkt % plot(kol,rad,'go'); if (BW1(rad,kol)== 0) & (BW1(rad-10,kol) == 0) & (BW1(rad-10,kol-8) == 0) &(BW1(rad-10,kol+8) == 0) break; end kol=kol+5; if kol >= 230 kol = 10; rad=rad-1; if rad