
%% Line Extraction (Script)
%
% Cycles through \images\ folder and prompts for line-extraction (LSD) for
% each image. 
%
%

%% Script Setup

close all;
clc;

addpath('./common/');

rng(0);


%% Find Supported Images

fprintf('Line Extraction...\n');
dirPath = './images/';
outPath = './line_points/';
suppFiles = {'jpg', 'png', 'ppm'};

[imgNames, nImgs] = find_supported_files(dirPath, suppFiles);
fprintf('\t\tFound %d Images\n', nImgs);


%% Apply Line-Manipulator GUI to select images

%cycle-through images -prompting for line-extraction
fprintf('\tLine Manipulator GUI...\n');
[selectImgNames] = select_files(imgNames, '^(?<group>[a-zA-Z0-9-]+)_', 'Image');

for i = 1:length(selectImgNames),
        
    fprintf('\t\tExtracting lines from %s\n', selectImgNames{i});
    h = line_manipulator_gui(selectImgNames{i}, ...
                             dirPath, ...
                             outPath);
    uiwait(h);

end
 
fprintf('...line extraction complete.\n');
   

