Commit abb2d4cf authored by Eamon Doyle's avatar Eamon Doyle
Browse files

updates for massively increased speed

parent ee1c78a4
......@@ -432,45 +432,101 @@ if ~isempty(text)
set(handles.progressText,'String',text);
end
function []=currentLine
s=dbstack;
line=s(2).line;
display(['At ' s.name 'line ' line]);
function redrawImage(hObject, eventdata, handles)
axes(handles.axes1);
%st = dbstack;
%display(['Start ' st.name]);
%currentLine
%tic;
%axes(handles.axes1);
%currentLine;toc;
images = handles.imageMat;
%h = imagesc(images(:,:,1,1),'HitTest','off');
cs = handles.currentSlice;
%currentLine;toc;
gridsize = handles.lungGridSize;
newim = repmat(images(:,:,1,cs),1,1,3);
newim = double(newim);
newim = newim ./ max(newim(:));
lms = handles.lungGridSize;
imsize = size(images);
overlay = zeros(size(newim));
if lms > -1
for n=1:size(handles.lungMatrix,1)-1
for m=1:size(handles.lungMatrix,2)-1
xx = n*lms;
yy = m*lms;
switch handles.lungMatrix(m,n,1,handles.currentSlice)
% for n=1:size(handles.lungMatrix,1)-1
% for m=1:size(handles.lungMatrix,2)-1
% xx = n*lms;
% yy = m*lms;
% switch handles.lungMatrix(m,n,1,handles.currentSlice)
% case 1
% cd = [0.2, 0.2, 0.0];
% case 2
% cd = [0.4,0,0];
% case 3
% cd = [0,0.4,0];
% case 4
% cd = [0.1,0.1,0.5];
% otherwise
% cd = [0 0 0];
% end
%
%
% overlay(yy:yy+lms, xx:xx+lms,1)=cd(1);
% overlay(yy:yy+lms, xx:xx+lms,2)=cd(2);
% overlay(yy:yy+lms, xx:xx+lms,3)=cd(3);
% end
% end
lungmat2 = repmat(imresize(handles.lungMatrix(:,:,1,handles.currentSlice), lms, 'nearest'),[1,1,3]);
for mcolor = 1:4
switch mcolor
case 1
cd = [0.2, 0.2, 0.0];
cmat = [0.5 0.5 0];
case 2
cd = [0.4,0,0];
cmat = [0 0 1];
case 3
cd = [0,0.4,0];
cmat = [0 1 0];
case 4
cd = [0.1,0.1,0.5];
otherwise
cd = [0 0 0];
cmat = [0.75 0 0 ];
end
overlay(yy:yy+lms, xx:xx+lms,1)=cd(1);
overlay(yy:yy+lms, xx:xx+lms,2)=cd(2);
overlay(yy:yy+lms, xx:xx+lms,3)=cd(3);
%[x,y,i] = find(lungmat2==mcolor)
%color2 = [0 0 1];
%color2 = reshape(color2,[1,1,3]);
for itr = 1:3
lungmathold = lungmat2(:,:,itr);
lungmathold(find(lungmathold==mcolor)) = cmat(itr);
lungmat2(:,:,itr) = lungmathold;
end
%overlay(x,y,1) = cmat(1);
%overlay(x,y,2) = cmat(2);
%overlay(x,y,3) = cmat(3);
end
a = size(lungmat2);
b = size(overlay);
c = b - a;
%currentLine
%toc;
overlay = padarray(lungmat2,c(1:2),0,'post');
end
%size(newim)
%size(overlay)
newim = newim + overlay;
......@@ -481,20 +537,26 @@ set(h,'PickableParts','none')
set(handles.sliceNum, 'String', num2str(handles.currentSlice));
set(handles.sliceCount,'String',sprintf('/ %i',size(images,4)));
if lms > -1
gridColor = [0.2,0.4,0.2];
hold on; for n=0:gridsize:imsize(1);
h = plot([n,n],[0,imsize(2)],'g');
h = plot([n,n],[0,imsize(2)],'Color',gridColor);
set(h,'HitTest','off')
set(h,'PickableParts','none')
%set(h,'ButtonDownFcn',@axes1_ButtonDownFcn)
end
for n=0:gridsize:imsize(2);
h = plot([0,imsize(1)],[n,n],'g');
h = plot([0,imsize(1)],[n,n],'Color',gridColor);
set(h,'HitTest','off')
set(h,'PickableParts','none')
%set(h,'ButtonDownFcn',@axes1_ButtonDownFcn)
end
%handles
end
%currentLine
%toc;
......@@ -591,7 +653,7 @@ lungMatrix = zeros(floor(imsize(1)./gridsize),floor(imsize(2)./gridsize),imsize(
handles.lungMatrix = lungMatrix;
handles.lungGridSize = gridsize;
hold on; for n=0:gridsize:imsize(1);
h = plot([n,n],[0,imsize(2)],'g');
h = plot([n,n],[0,imsize(2)],'Color',[0.2,0.4,0.2]);
%set(h,'HitTest','off')
set(h,'ButtonDownFcn',@axes1_ButtonDownFcn)
end
......@@ -616,6 +678,10 @@ function axes1_ButtonDownFcn(hObject, eventdata, handles)
% handles structure with handles and user data (see GUIDATA)
%gca;
%st = dbstack;
%display(['Start ' st.name]);
%tic;
drawnow
handles = guidata(hObject);
%colormap('gray');
......@@ -636,8 +702,8 @@ end
lungGridSize = handles.lungGridSize;
lungGridMatSize = size(handles.lungMatrix);
lungMatLoc = floor(currentBox);
lmy = floor(lungMatLoc(1)./size(handles.imageMat,2)*lungGridMatSize(2));
lmx = floor(lungMatLoc(2)./size(handles.imageMat,1)*lungGridMatSize(1));
lmy = floor(lungMatLoc(1)./size(handles.imageMat,2)*lungGridMatSize(2))+1;
lmx = floor(lungMatLoc(2)./size(handles.imageMat,1)*lungGridMatSize(1))+1;
currentSlice = get(handles.slider2,'Value');
if handles.debug > 3
lungGridMatSize
......@@ -661,6 +727,9 @@ redrawImage(hObject, eventdata, handles);
% Update handles structure
guidata(hObject, handles);
%toc;
%display(['Stop ' st.name]);
function mouseClick(~,~)
disp('yep')
get(gca,'CurrentPoint')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment