-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremoveBorders.m
48 lines (47 loc) · 1.05 KB
/
removeBorders.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
function [outImage ] = removeBorders( inImage )
%Detects and removes borders from images
% Detailed explanation goes here
outImage = inImage(1:end-18, :, :);
% image = rgb2gray(inImage);
% rowSum = sum(image,1);
% colSum = sum(image,2);
% figure, bar(rowSum);
% figure, bar(colSum);
%
% rowStd = std(colSum);
% colStd = std(rowSum);
% factor = 1;
% top = 1;
% bottom = size(inImage,1);
% left = 1;
% right = size(inImage,2);
%
% for rows = 2:numel(colSum)
% if abs(colSum(rows)-colSum(rows-1)) > factor*rowStd
% top = rows;
% break;
% end
% end
%
% for rows = numel(colSum):-1:2
% if abs(colSum(rows)-colSum(rows-1)) > factor*rowStd
% bottom = rows;
% break;
% end
% end
%
% for cols = 2:numel(rowSum)
% if abs(rowSum(cols)-rowSum(cols-1)) > factor*colStd
% left = cols;
% break;
% end
% end
%
% for cols = numel(rowSum):-1:2
% if abs(rowSum(cols)-rowSum(cols-1)) > factor*colStd
% right = cols;
% break;
% end
% end
% outImage = inImage(top:bottom, left:right,:);
end