Subversion Repositories seema-scanner

Rev

Rev 209 | Rev 211 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 209 Rev 210
1
function MSE = alignSubScansMarkers(calibrationFileName, scanDir, alnFileName)
1
function MSE = alignSubScansMarkers(calibrationFileName, scanDir, alnFileName)
2
%ALIGNSUBSCANSMARKERS Determines an exact alignment of sub scans (scans
2
%ALIGNSUBSCANSMARKERS Determines an exact alignment of sub scans (scans
3
% from e.g. one revolution of the rotation stage). 
3
% from e.g. one revolution of the rotation stage). 
4
% The method searches for circular white markers of the specified diameter.
4
% The method searches for circular white markers of the specified diameter.
5
% White frames corresponding to each sub scan must be available.
5
% White frames corresponding to each sub scan must be available.
6
% A coarse alignment in the form of an aln-file must be provided. 
6
% A coarse alignment in the form of an aln-file must be provided. 
7
%
7
%
8
% 2017 Jakob Wilm, DTU
8
% 2017 Jakob Wilm, DTU
9
 
9
 
10
calibration = readOpenCVXML(calibrationFileName);
10
calibration = readOpenCVXML(calibrationFileName);
11
initialAlign = readMeshLabALN(alnFileName);
11
initialAlign = readMeshLabALN(alnFileName);
12
whiteFrameDirs = dir(fullfile(scanDir, 'sequence_*'));
12
whiteFrameDirs = dir(fullfile(scanDir, 'sequence_*'));
13
 
13
 
14
assert(length(whiteFrameDirs) == length(initialAlign));
14
assert(length(whiteFrameDirs) == length(initialAlign));
15
 
15
 
16
nSubScans = length(whiteFrameDirs);
16
nSubScans = length(whiteFrameDirs);
17
 
17
 
18
for i=1:nSubScans
18
for i=1:nSubScans
19
    frame0 = imread(fullfile(whiteFrameDirs(i).folder, whiteFrameDirs(i).name, 'frames0_0.png'));
19
    frame0 = imread(fullfile(whiteFrameDirs(i).folder, whiteFrameDirs(i).name, 'frames0_0.png'));
20
    frame1 = imread(fullfile(whiteFrameDirs(i).folder, whiteFrameDirs(i).name, 'frames1_0.png'));
20
    frame1 = imread(fullfile(whiteFrameDirs(i).folder, whiteFrameDirs(i).name, 'frames1_0.png'));
21
    
21
    
22
    %BW0 = im2bw(frame0, graythresh(frame0));
22
    %BW0 = im2bw(frame0, graythresh(frame0));
23
    %RP0 = regionprops(BW0, 'Area', 'Solidity', 'Eccentricity', 'Orientation', 'Centroid');
23
    %RP0 = regionprops(BW0, 'Area', 'Solidity', 'Eccentricity', 'Orientation', 'Centroid');
24
 
24
 
25
    gray0 = rgb2gray(frame0);
25
    gray0 = rgb2gray(frame0);
26
    
26
    
27
	[edge0, tr] = edge(gray0, 'Canny', [0.08 0.1], 2);
27
	[edge0, tr] = edge(gray0, 'Canny', [0.08 0.1], 2);
28
        
28
    
-
 
29
    %edge0 = edge0(1190:1290, 1975:2045);
29
    %figure; imagesc(edge0);
30
    %figure; imagesc(edge0);
30
    
31
    
31
    ep = struct('minMajorAxis', 15, 'maxMajorAxis', 25, 'minAspectRatio', 0.3, 'numBest', 50);
32
    ep = struct('minMajorAxis', 25, 'maxMajorAxis', 35, 'minAspectRatio', 0.4, 'numBest', 10, 'randomize', 2, 'smoothStddev', 1);
32
    e0 = ellipseDetection(edge0, ep);
33
    e0 = ellipseDetection(edge0, ep);
33
    
34
    
34
    figure; hold('on'); imshow(edge0); ellipse(e0(:,3), e0(:,4), e0(:,5)*pi/180, e0(:,1), e0(:,2), 'r'); 
35
    figure; hold('on'); imshow(edge0); ellipse(e0(:,3), e0(:,4), e0(:,5)*pi/180, e0(:,1), e0(:,2), 'r'); 
35
    
36
    
36
    
37
    
37
    
38
    
38
end
39
end
39
 
40
 
40
end
41
end
41
 
42
 
42
 
43