-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplatelengthspartial3.m
39 lines (28 loc) · 1.63 KB
/
templatelengthspartial3.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
function [ lengthtemplate, fulllengthtemplate, strokeidentifier ] = templatelengthspartial3( example, fullexample, numslices, strokerelation )
%TEMPLATELENGTHS Summary of this function goes here
% Detailed explanation goes here
x = find(any(example,2),1,'first'):find(any(example,2),1,'last');
y = find(any(example),1,'first'):find(any(example),1,'last');
trimmedexample = example(x, y);
minx=min(x);
maxx=max(x);
[rowdim,coldim] = size(trimmedexample);
lengthinterval = rowdim/(numslices+2);
%the very edges tend to be points so move the pieces in a bit.
trimmedexample = trimmedexample(round(1+lengthinterval:lengthinterval:rowdim-lengthinterval),:);
% [rowdim,coldim]=size(trimmedexample);
% test=zeros(rowdim,coldim,3);
% test(:,:,1) = trimmedexample;
% figure;
% image(logical(test));
[lengthtemplate,tempstrokeidentifier] = templatelengthsidentified( trimmedexample, strokerelation );
lengthtemplate(:,all(lengthtemplate==0,1))=[];
trimmedfullexample = fullexample(minx:maxx,:);
x = find(any(trimmedfullexample,2),1,'first'):find(any(trimmedfullexample,2),1,'last');
y = find(any(trimmedfullexample),1,'first'):find(any(trimmedfullexample),1,'last');
trimmedfullexample = trimmedfullexample(x, y);
trimmedfullexample = trimmedfullexample(round(1+lengthinterval:lengthinterval:rowdim-lengthinterval),:);
[fulllengthtemplate,strokeidentifier] = templatelengthsidentified( trimmedfullexample, strokerelation );
fulllengthtemplate(:,all(fulllengthtemplate==0,1))=[];
strokeidentifier(:,all(strokeidentifier==0,1))=[];
end