Professional Documents
Culture Documents
hnd.roi=uicontrol(hnd.mainfig,'units','normalized','style','pushbutton
',...
'position',[0.45 0.01 0.08 0.04],'string','ROI',...
'callback','gui_1013(''roi'')');
hnd.cor=uicontrol(hnd.mainfig,'units','normalized','style','pushbutto
n',...
'position',[0.55 0.01 0.1 0.04],'string','Correlation',...
'callback','gui_1013(''cor'')');
hnd.edit3=uicontrol(hnd.mainfig,'units','normalized','style','edit',...
'position',[0.65 0.01 0.08 0.04],'backgroundcolor',[1 1 1],...
'HorizontalAlignment','left','String','0.9',...
'callback','gui_1013(''cor'')');
hnd.hist=uicontrol(hnd.mainfig,'units','normalized','style','pushbutto
n',...
'position',[0.75 0.01 0.08 0.04],'string','Hist',...
'callback','gui_1013(''hist'')','enable','on');
hnd.quit=uicontrol(hnd.mainfig,'units','normalized','style','pushbutto
n',...
'position',[0.9 0.01 0.08 0.04],'string','Quit',...
'callback','gui_1013(''quit'')');
data.pt1=get(hnd.sub1,'currentpoint');%
data.pt1=data.pt1(1,1:2);
set(gcf,'windowbuttonmotionfcn','gui_1013(''move'')');
%
set(gcf,'windowbuttonupfcn','gui_1013(''up'')');
%
elseif strcmp(action,'move')%
data.pt2=get(hnd.sub1,'currentpoint');%
data.pt2=data.pt2(1,1:2);
set(hnd.line,'color',[0.5 0.5 0.5],...
'xdata',[data.pt1(1) data.pt2(1) data.pt2(1) data.pt1(1)
data.pt1(1)],...
'ydata',[data.pt1(2) data.pt1(2) data.pt2(2) data.pt2(2)
data.pt1(2)],...
'erasemode','xor','linestyle','--')
%
elseif strcmp(action,'up')%
data.pt2=get(hnd.sub1,'currentpoint');
data.pt2=data.pt2(1,1:2);
set(gcf,'buttondownfcn','');%
set(gcf,'windowbuttonmotionfcn','');%
set(gcf,'windowbuttonupfcn','');%
set(hnd.line,'color',[0 0 1],...
'xdata',[data.pt1(1) data.pt2(1) data.pt2(1) data.pt1(1)
data.pt1(1)],...
'ydata',[data.pt1(2) data.pt1(2) data.pt2(2) data.pt2(2)
data.pt1(2)],...
'erasemode','xor','linestyle','--')
% erasemode() none
drawnow
set(gcf,'pointer','arrow');%
if data.pt1(1)>data.pt2(1)%
pttemp=data.pt1(1);%
data.pt1(1)=data.pt2(1);%
data.pt2(1)=pttemp;
end
if data.pt1(2)>data.pt2(2)
pttemp=data.pt1(2);
data.pt1(2)=data.pt2(2);
data.pt2(2)=pttemp;
end
if data.pt1(1)<1,data.pt1(1)=1;end%
if data.pt2(1)<2,data.pt2(1)=2;end
if data.pt1(1)>127,data.pt1(1)=127;end
if data.pt2(1)>128,data.pt2(1)=128;end
if data.pt1(2)<1,data.pt1(2)=1;end
if data.pt2(2)<2,data.pt2(2)=2;end
if data.pt1(2)>127,data.pt1(2)=127;end
if data.pt2(2)>128,data.pt2(2)=128;end
%
data.W=length(round(data.pt1(1)):round(data.pt2(1)));
data.H=length(round(data.pt1(2)):round(data.pt2(2)));
data.cind=round(data.pt1(1));
data.rind=round(data.pt1(2));
set(hnd.hist,'enable','on')
elseif strcmp(action,'cor')% hnd.cor
hnd.sub3=axes('position',[0.05 0.1 0.4 0.4],'ydir','reverse',...
'xlim',[1 128],'ylim',[1 128]);
axis off
hnd.img3=image('cdata',[]);
data.cor=zeros(128,128);
temp=data.img1(data.rind:(data.rind+data.H-1),data.cind:
(data.cind+data.W-1));
%
denomi=sum(sum(temp.*temp));
for r=1:128-data.H+1% correlation
for c=1:128-data.W+1
nom=sum(sum(temp.*data.img2(r:r+data.H-1,c:c+data.W-1)));
denomj=sum(sum(data.img2(r:r+data.H-1,c:c+data.W1).*data.img2(r:r+data.H-1,c:c+data.W-1)));
data.cor(r,c)=nom/sqrt((denomi*denomj));
end
end
data.corimg=zeros(128,128);%
x=get(hnd.edit3,'string');% threshold
x=str2num(x);
if x>1,x=0.9999;end
if x<0,x=0;end
set(hnd.edit3,'string',num2str(x));
ind=find(data.cor>x);% threshold
tdata=data.cor(ind);%
tdata=scale(tdata,129,256);% rescale 129 256
data.corimg(ind)=tdata;% data.corimg
redmap=[zeros(64,2) linspace(0.6,1,64)';linspace(0.6,1,64)'
zeros(64,1) [linspace(1,0,32)';zeros(32,1)]];
cmap=[gray(128);redmap];
% colormap
colormap(cmap)
set(hnd.img3,'cdata',data.corimg);% coelaion
elseif strcmp(action,'hist')% hist
set(hnd.sub4,'visible','on')
data.g=reshape(data.cor,[1 128*128]);% correlaiton
1*16384
k=hist(data.g*255,255);% histogram
set(hnd.histline,'xdata',[0:254],'ydata',k,'color','b');%
elseif strcmp(action,'quit')% hnd.quit
close(gcf)% figure
clear global hnd data%
end