Subversion Repositories seema-scanner

Rev

Rev 204 | Rev 210 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 204 Rev 209
Line 1... Line 1...
1
function [ output_args ] = alignSubScansMarkers(calibrationFileName, alnFileName, scanDir)
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. This is
6
% A coarse alignment in the form of an aln-file must be provided. 
7
% output from the scanner by default based on rotation axis alignment.
-
 
8
%
7
%
9
% 2017 Jakob Wilm, DTU
8
% 2017 Jakob Wilm, DTU
10
 
9
 
-
 
10
calibration = readOpenCVXML(calibrationFileName);
-
 
11
initialAlign = readMeshLabALN(alnFileName);
-
 
12
whiteFrameDirs = dir(fullfile(scanDir, 'sequence_*'));
-
 
13
 
-
 
14
assert(length(whiteFrameDirs) == length(initialAlign));
-
 
15
 
-
 
16
nSubScans = length(whiteFrameDirs);
-
 
17
 
-
 
18
for i=1:nSubScans
-
 
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'));
-
 
21
    
-
 
22
    %BW0 = im2bw(frame0, graythresh(frame0));
-
 
23
    %RP0 = regionprops(BW0, 'Area', 'Solidity', 'Eccentricity', 'Orientation', 'Centroid');
-
 
24
 
-
 
25
    gray0 = rgb2gray(frame0);
-
 
26
    
-
 
27
	[edge0, tr] = edge(gray0, 'Canny', [0.08 0.1], 2);
-
 
28
        
-
 
29
    %figure; imagesc(edge0);
-
 
30
    
-
 
31
    ep = struct('minMajorAxis', 15, 'maxMajorAxis', 25, 'minAspectRatio', 0.3, 'numBest', 50);
-
 
32
    e0 = ellipseDetection(edge0, ep);
-
 
33
    
-
 
34
    figure; hold('on'); imshow(edge0); ellipse(e0(:,3), e0(:,4), e0(:,5)*pi/180, e0(:,1), e0(:,2), 'r'); 
-
 
35
    
-
 
36
    
-
 
37
    
-
 
38
end
-
 
39
 
11
end
40
end
12
 
41