-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsortvalidpoints.m
69 lines (62 loc) · 1.93 KB
/
sortvalidpoints.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
% written by Chris
function [validx,validy,resnormx]=sortvalidpoints(fitxy)
% This function will free the good peaks from fitxy, captured by
% peak_labelling, and send them back as validx and validy. The loops you
% will find are not absolutely necessary and reduce the speed of this
% function tremendously and will be changed probably in a future version if
% there is need.
sizefitxy=size(fitxy);
looppoints=sizefitxy(1,1);
loopimages=sizefitxy(1,2)/12;
validpoints=fitxy(:,sizefitxy(1,2)-11);
validnumber(:,:)=validpoints(1:(max(find(validpoints))));
for i=1:loopimages-1
counter=1;
for j=1:looppoints
if counter<length(validnumber)+1
if fitxy(j,i*12-11)==validnumber(counter)
resnormx(counter,i)=fitxy(j,i*12);
cropwidthx(counter,i)=fitxy(j,i*12-2);
counter=counter+1;
end
end
end
end
resnormxtemp(:,:)=resnormx(1:length(validnumber),:);
resnormx=resnormxtemp;
clear resnormxtemp;
normresxtest=mean((resnormx./cropwidthx)')';
number=1:1:looppoints;
figure, plot(1:length(validnumber),normresxtest,'.');
drawnow;
%set new normres
counter=1;
for i=1:length(validnumber)
if abs(normresxtest(i,1))<10
validnumbertest(counter,1)=validnumber(i,1);
counter=counter+1;
end
end
for i=1:loopimages-1
counter=1;
for j=1:looppoints
if counter<length(validnumbertest)+1
if fitxy(j,i*12-11)==validnumbertest(counter)
validx(counter,i)=fitxy(j,i*12-9);
validy(counter,i)=fitxy(j,i*12-5);
resnormx(counter,i)=fitxy(j,i*12);
counter=counter+1;
end
end
end
end
pointnumber=size(validx);
validxtemp(:,:)=validx(1:pointnumber(1,1),:);
validx=validxtemp;
clear validxtemp;
validytemp(:,:)=validy(1:pointnumber(1,1),:);
validy=validytemp;
clear validytemp;
resnormxtemp(:,:)=resnormx(1:pointnumber(1,1),:);
clear resnormx;
resnormx=resnormxtemp;