Skip to content

Commit

Permalink
Lesion candidate extraction from a data set abstracted on a separate …
Browse files Browse the repository at this point in the history
…function
  • Loading branch information
ignaciorlando committed Oct 23, 2017
1 parent 395eb47 commit cf68050
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 33 deletions.
37 changes: 4 additions & 33 deletions RedLesionDetection/scripts/script_extract_lesion_candidates.m
Expand Up @@ -12,40 +12,11 @@
% prepare dataset path
dataset_path = fullfile(data_path, datasetName);
% prepare output path
if (exist('output_path', 'var') == 0)
output_path = fullfile(dataset_path, strcat(type_of_lesion, '_candidates'));
end
output_path = fullfile(dataset_path, strcat(type_of_lesion, '_candidates'));
if (exist(output_path, 'dir') == 0)
mkdir(output_path);
end

% get image filenames
img_names = getMultipleImagesFileNames(fullfile(root_path, 'images'));
% get masks filenames
mask_names = getMultipleImagesFileNames(fullfile(root_path, 'masks'));

% For each of the images
for i = 1 : length(img_names)

fprintf('Extracting candidates from image %i/%i\n', i, length(img_names));

% open i-th image and its corresponding FOV mask, OD and vessel
% segmentation
I = imread(fullfile(root_path, 'images', img_names{i}));
mask = imread(fullfile(root_path, 'masks', mask_names{i}));

% get candidates
tic
[ current_candidates ] = getLesionCandidates(I, mask, L0, step, L, K, px);
toc

% get only the image name
[~, filename, extension] = fileparts(img_names{i});
if (~strcmp(extension, '.gif'))
filename = strcat(filename, '.gif');
end

% save the image
imwrite(current_candidates, fullfile(output_path, strcat(filename)));

end
% Get all candidates from images
getLesionCandidatesFromDataset(fullfile(root_path, 'images'), ...
fullfile(root_path, 'masks'), output_path, L0, step, L, K, px);
@@ -0,0 +1,33 @@

function getLesionCandidatesFromDataset(image_path, masks_path, output_path, L0, step, L, K, px)

% get image filenames
img_names = getMultipleImagesFileNames(image_path);
% get masks filenames
mask_names = getMultipleImagesFileNames(masks_path);

% For each of the images
for i = 1 : length(img_names)

fprintf('Extracting candidates from image %i/%i\n', i, length(img_names));

% open i-th image and its corresponding FOV mask, OD and vessel
% segmentation
I = imread(fullfile(image_path, img_names{i}));
mask = imread(fullfile(masks_path, mask_names{i}));

% get candidates
tic
[ current_candidates ] = getLesionCandidates(I, mask, L0, step, L, K, px);
toc

% get only the image name
[~, filename, extension] = fileparts(img_names{i});
if (~strcmp(extension, '.gif'))
filename = strcat(filename, '.gif');
end

% save the image
imwrite(current_candidates, fullfile(output_path, strcat(filename)));

end

0 comments on commit cf68050

Please sign in to comment.