Subversion Repositories seema-scanner

Rev

Rev 204 | Rev 210 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

function MSE = alignSubScansMarkers(calibrationFileName, scanDir, alnFileName)
%ALIGNSUBSCANSMARKERS Determines an exact alignment of sub scans (scans
% from e.g. one revolution of the rotation stage). 
% The method searches for circular white markers of the specified diameter.
% White frames corresponding to each sub scan must be available.
% A coarse alignment in the form of an aln-file must be provided. 
%
% 2017 Jakob Wilm, DTU

calibration = readOpenCVXML(calibrationFileName);
initialAlign = readMeshLabALN(alnFileName);
whiteFrameDirs = dir(fullfile(scanDir, 'sequence_*'));

assert(length(whiteFrameDirs) == length(initialAlign));

nSubScans = length(whiteFrameDirs);

for i=1:nSubScans
    frame0 = imread(fullfile(whiteFrameDirs(i).folder, whiteFrameDirs(i).name, 'frames0_0.png'));
    frame1 = imread(fullfile(whiteFrameDirs(i).folder, whiteFrameDirs(i).name, 'frames1_0.png'));
    
    %BW0 = im2bw(frame0, graythresh(frame0));
    %RP0 = regionprops(BW0, 'Area', 'Solidity', 'Eccentricity', 'Orientation', 'Centroid');
 
    gray0 = rgb2gray(frame0);
    
        [edge0, tr] = edge(gray0, 'Canny', [0.08 0.1], 2);
        
    %figure; imagesc(edge0);
    
    ep = struct('minMajorAxis', 15, 'maxMajorAxis', 25, 'minAspectRatio', 0.3, 'numBest', 50);
    e0 = ellipseDetection(edge0, ep);
    
    figure; hold('on'); imshow(edge0); ellipse(e0(:,3), e0(:,4), e0(:,5)*pi/180, e0(:,1), e0(:,2), 'r'); 
    
    
    
end

end