/normxcorr/trunk

To get this branch, use:
bzr branch http://suren.me/webbzr/normxcorr/trunk
1 by Suren A. Chilingaryan
Initial import
1
% written by Chris
2
3
function [validx,validy,resnormx]=sortvalidpoints(fitxy)
4
5
% This function will free the good peaks from fitxy, captured by
6
% peak_labelling, and send them back as validx and validy. The loops you
7
% will find are not absolutely necessary and reduce the speed of this
8
% function tremendously and will be changed probably in a future version if
9
% there is need.
10
11
sizefitxy=size(fitxy);
12
looppoints=sizefitxy(1,1);
13
loopimages=sizefitxy(1,2)/12;
14
validpoints=fitxy(:,sizefitxy(1,2)-11);
15
validnumber(:,:)=validpoints(1:(max(find(validpoints))));
16
17
for i=1:loopimages-1
18
    counter=1;
19
    for j=1:looppoints
20
        if counter<length(validnumber)+1
21
            if fitxy(j,i*12-11)==validnumber(counter)
22
                resnormx(counter,i)=fitxy(j,i*12);
23
                cropwidthx(counter,i)=fitxy(j,i*12-2);
24
                counter=counter+1;
25
            end
26
        end
27
    end
28
end
29
30
resnormxtemp(:,:)=resnormx(1:length(validnumber),:);
31
resnormx=resnormxtemp;
32
clear resnormxtemp;
33
normresxtest=mean((resnormx./cropwidthx)')';
34
number=1:1:looppoints;
35
figure, plot(1:length(validnumber),normresxtest,'.');
36
drawnow;
37
38
%set new normres
39
counter=1;
40
for i=1:length(validnumber)
41
    if abs(normresxtest(i,1))<10
42
        validnumbertest(counter,1)=validnumber(i,1);
43
        counter=counter+1;
44
    end
45
end
46
47
for i=1:loopimages-1
48
    counter=1;
49
    for j=1:looppoints
50
       if counter<length(validnumbertest)+1
51
            if fitxy(j,i*12-11)==validnumbertest(counter)
52
                validx(counter,i)=fitxy(j,i*12-9);
53
                validy(counter,i)=fitxy(j,i*12-5);
54
                resnormx(counter,i)=fitxy(j,i*12);
55
                counter=counter+1;
56
            end
57
        end
58
    end
59
end
60
pointnumber=size(validx);
61
validxtemp(:,:)=validx(1:pointnumber(1,1),:);
62
validx=validxtemp;
63
clear validxtemp;
64
validytemp(:,:)=validy(1:pointnumber(1,1),:);
65
validy=validytemp;
66
clear validytemp;
67
resnormxtemp(:,:)=resnormx(1:pointnumber(1,1),:);
68
clear resnormx;
69
resnormx=resnormxtemp;