|
| 1 | +function changeImage(key) |
| 2 | + |
| 3 | +% advances to the next image when a key is pressed |
| 4 | +% |
| 5 | +% SYNOPSIS changeImage(key) |
| 6 | +% |
| 7 | +% Alexandre Matov, 11-Mar-2004 |
| 8 | + |
| 9 | +handles = guidata(findobj('Name','manTrack')); |
| 10 | +switch key |
| 11 | + case 1 |
| 12 | + if handles.no>1 & handles.no<41 |
| 13 | + handles.no = handles.no - 1; |
| 14 | + flag = -1; |
| 15 | + if ishandle(handles.neighborPlot) |
| 16 | + delete(handles.neighborPlot); |
| 17 | + end |
| 18 | + if ~isempty(handles.neighborPlot) |
| 19 | + handles.neighborPlot = []; |
| 20 | + end |
| 21 | + else |
| 22 | + msgbox('there are 40 images in the stack (min number 1 and max number 40)') |
| 23 | + return |
| 24 | + end |
| 25 | + case 2 |
| 26 | + if handles.no>0 & handles.no<40 |
| 27 | + handles.no = handles.no + 1; |
| 28 | + flag = 1; |
| 29 | + if ishandle(handles.neighborPlot) |
| 30 | + delete(handles.neighborPlot); |
| 31 | + end |
| 32 | + if ~isempty(handles.neighborPlot) |
| 33 | + handles.neighborPlot = []; |
| 34 | + end |
| 35 | + else |
| 36 | + msgbox('there are 40 images in the stack (min number 1 and max number 40)') |
| 37 | + return |
| 38 | + end |
| 39 | +end |
| 40 | +fh = findall(0, 'Name', 'Spindle'); |
| 41 | +if handles.no>0 & handles.no<41 |
| 42 | + handles.image = Gauss2D(double(imread(char(handles.listImages(handles.no)))), 1); |
| 43 | +else |
| 44 | + msgbox('there are 40 images in the stack') |
| 45 | + return |
| 46 | +end |
| 47 | +figure(fh) |
| 48 | +set(handles.title,'String',['Frame ',num2str(handles.no)]); |
| 49 | +guidata(findobj('Name', 'manTrack'), handles); |
| 50 | +set(findobj('Type','image'),'CData', handles.image); |
| 51 | +refresh(fh); |
| 52 | +hold on |
| 53 | +delete(handles.currentSp); |
| 54 | +haSp=plot(handles.candsR.Lmax(2), handles.candsR.Lmax(1), 'r*');%initial speckle |
| 55 | + |
| 56 | +% Next, plot all the detected speckles. First, load in the cands structure |
| 57 | +if isunix == 1 |
| 58 | + temp_cands_fname = strcat('/unc/manTrackWT2s/speckles/cands0', num2str(handles.no+50), '.mat'); |
| 59 | +else |
| 60 | + temp_cands_fname = strcat('U:\manTrackWT2s\speckles\cands0', num2str(handles.no+50), '.mat'); |
| 61 | +end |
| 62 | +load(temp_cands_fname); % Load in the new cand structure. |
| 63 | +cands=cands(find([cands.status]==1)); % do not consider the insignificant ones!! |
| 64 | + |
| 65 | +[temp0 length] = size(cands); |
| 66 | +% find the previous point that has already been recorded. |
| 67 | +if ~isempty(handles.speckleCo) |
| 68 | + list = sort([handles.speckleCo(:,1);handles.noInit]); |
| 69 | + if handles.no > list(end) |
| 70 | + indx = find(handles.speckleCo(:,1)==list(end)); |
| 71 | + elseif handles.no < list(1) |
| 72 | + indx = find(handles.speckleCo(:,1)==list(1)); |
| 73 | + else |
| 74 | + indx = find(handles.speckleCo(:,1)==(handles.no)); |
| 75 | + if isempty(indx) |
| 76 | + indx = find(handles.speckleCo(:,1)==(handles.no-flag*1)); |
| 77 | + if isempty(indx) |
| 78 | + indx = find(handles.speckleCo(:,1)==(handles.no-flag*2)); |
| 79 | + end |
| 80 | + end |
| 81 | + end |
| 82 | + % indx = find(handles.speckleCo(:, 1) == (handles.no - 1)); % Find saved coordinate ????flag* |
| 83 | +else |
| 84 | + indx = []; % No previous saved coordinate. |
| 85 | +end % indx can be improved - dont in one for loop!! |
| 86 | +RADIUS = 30; |
| 87 | +handles.neighbors.length = 0; |
| 88 | +if (handles.no == handles.noInit) |
| 89 | + handles.currentSp = haSp; |
| 90 | + guidata(findobj('Name','manTrack'),handles); |
| 91 | + return; |
| 92 | +end |
| 93 | +if isempty(indx) % Previous point is the first speckle |
| 94 | + previous_point = handles.candsR; |
| 95 | + for i = 1 : length |
| 96 | + temp0 = (cands(i).Lmax - previous_point.Lmax).^2; |
| 97 | + if (temp0 < RADIUS^2) |
| 98 | + handles.neighbors.length = handles.neighbors.length + 1; |
| 99 | + handles.neighbors.points(handles.neighbors.length, 1:2) = cands(i).Lmax(1:2); |
| 100 | + handles.neighborPlot(end + 1, 1) = plot(cands(i).Lmax(2), cands(i).Lmax(1), 'g.'); |
| 101 | + set(handles.neighborPlot(end, 1),'ButtonDownFcn','plotSpeckle'); |
| 102 | + end |
| 103 | + end |
| 104 | +else |
| 105 | + previous_point_coordinate = [handles.speckleCo(indx, 3) handles.speckleCo(indx, 2)]; |
| 106 | + for i = 1 : length |
| 107 | + temp0 = (cands(i).Lmax - previous_point_coordinate).^2; |
| 108 | + if (temp0 < RADIUS^2) |
| 109 | + handles.neighbors.length = handles.neighbors.length + 1; |
| 110 | + handles.neighbors.points(handles.neighbors.length, 1:2) = cands(i).Lmax(1:2); |
| 111 | + handles.neighborPlot(end + 1, 1) = plot(cands(i).Lmax(2), cands(i).Lmax(1), 'g.'); |
| 112 | + set(handles.neighborPlot(end, 1),'ButtonDownFcn','plotSpeckle'); |
| 113 | + end |
| 114 | + end |
| 115 | +end |
| 116 | +handles.tempCands = cands; |
| 117 | +handles.currentSp = haSp; |
| 118 | +guidata(findobj('Name','manTrack'),handles); |
0 commit comments