Skip to content

Commit

Permalink
Merge pull request #6 from UniBoDS4H/fix/api/algorithms-search
Browse files Browse the repository at this point in the history
Feat/api/largest-segmentation
  • Loading branch information
drudilorenzo authored Apr 3, 2023
2 parents 99f7f18 + 01c158a commit 8958779
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 3 deletions.
35 changes: 34 additions & 1 deletion api/algorithms/algorithm_getLargestSegmentation.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
function res = getLargestSegmentation(segmentations)
function res = algorithm_getLargestSegmentation(segmentations)
% AUTHOR: Lorenzo Drudi (E-mail: lorenzo.drudi5@studio.unibo.it)
% DATE: March 24, 2022
% NAME: TDSFT (version 1.0)
%
% PARAMETERS:
% segmentations: the aligned segmentations to be fused together
%
% OUTPUT:
% res: the resulting segmentation
%
% DESCRIPTION:
% Fuse all the segmentations together overlapping them and getting the largest possible segmentation which contains all the inputs.
%

% initialize the overlap

disp('Getting the largest segmentation...');

first = segmentations{1};
[m,n] = size(first);
overlap = zeros(m, n, 'uint8');

% overlap all the segmentations
for i=1:length(segmentations)
seg = uint8(~segmentations{i});
overlap = overlap + seg;
end

overlap = imbinarize(overlap);
overlap = uint8(~overlap);

% fill the resulting segmentation and get the perimeter
fillOverlap = imfill(overlap, 'holes');
res = bwperim(fillOverlap);
end
2 changes: 1 addition & 1 deletion api/algorithms/algorithm_localMapStaple.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
function res = localMapStaple(segmentations)
function res = algorithm_localMapStaple(segmentations)
fprintf('Local map staple selected\n');
end
2 changes: 1 addition & 1 deletion api/algorithms/algorithm_staple.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
function res = staple(segmentations)
function res = algorithm_staple(segmentations)
fprintf('Staple selected\n');
end
18 changes: 18 additions & 0 deletions api/computeFusion.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function res = computeFusion(segmentations, algorithm)
% AUTHOR: Lorenzo Drudi (E-mail: lorenzo.drudi5@studio.unibo.it)
% DATE: March 20, 2022
% NAME: TDSFT (version 1.0)
%
% PARAMETERS:
% segmentations: the segmentations to be fused.
% algorithm: the algorithm to be used for the fusion process.
%
% OUTPUT:
% res: the result of the fusion process.
%
% DESCRIPTION:
% Fuse the segmentations using the specified algorithm.
algorithmName = getAlgorithmFullName(algorithm);
fun = str2func(algorithmName);
res = fun(alignedSegmentations);
end
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions api/utils/getAlgorithmFullName.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function fullName = getAlgorithmFullName(algorithm)
% AUTHOR: Lorenzo Drudi (E-mail: lorenzo.drudi5@studio.unibo.it)
% DATE: March 24, 2022
% NAME: TDSFT (version 1.0)
%
% PARAMETERS:
% algorithm: algorithm name.
%
% OUTPUT:
% fullName: fullName of the algorithm.
% DESCRIPTION:
% Get the full name of the specified algorithm.
% FullName: 'algorithm_' + algorithmName.

fullName = strcat('algorithm_', algorithm);
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions utils/processImage.m → api/utils/processImage.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@
% It adds more check to the segmentation to be able to recognize open lines and close dense lines.
%
% OUTPUT:
% cImg: image converted to 8 bit
% bw: image converted to black and white
% seg: segmentation of the object
%
% DESCRIPTION:
% - Converts the image to 8 bit
% - Convertes the image to black white
% - Get the segmentation (perimeter) of the object contained in the image.

% Check the channels of the image
% If the image has more than one channel but is not an rgb image, use only the first one
Expand Down
Binary file modified imageTDSFT.mlapp
Binary file not shown.
Binary file modified mainTDSFT.mlapp
Binary file not shown.

0 comments on commit 8958779

Please sign in to comment.