📄 untitled.m
字号:
global result;
global output;
val=0.52789;
if exist('imlincomb')
result = imlincomb(val, output, 1-val, outpu);
else
result = val .* output + (1-val) .* outpu;
end
axes(handles.axes6);
%place image onto the axes
image(result);
%remove the axis tick marks
axis off
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
% --- Executes during object creation, after setting all properties.
function slider8_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor',[.9 .9 .9]);
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on button press in togglebutton1.
function togglebutton1_Callback(hObject, eventdata, handles)
% hObject handle to togglebutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global pet
pet=imread(uigetfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...
'*.*','All Files' },'PET IMAGE',...
''));
c1=imread(uigetfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...
'*.*','All Files' },'ct soft tissue',...
''));
c2=imread(uigetfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...
'*.*','All Files' },'ct bone',...
''));
c3=imread(uigetfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...
'*.*','All Files' },'ct lung',...
''));
global output;
output=pet;
% UIWAIT makes untitled wait for user response (see UIRESUME)
% uiwait(handles.figure1);
axes(handles.axes1);
%place image onto the axes
image(c1);
%remove the axis tick marks
axis off
axes(handles.axes2);
%place image onto the axes
image(c2);
%remove the axis tick marks
axis off
axes(handles.axes3);
%place image onto the axes
image(c3);
%remove the axis tick marks
axis off
axes(handles.axes4);
%place image onto the axes
image(pet);
%remove the axis tick marks
axis off
% Choose default command line output for untitled
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
v1=.333333;
v2=.333333;
v3=.333334;
global temp
if exist('imlincomb')
temp = imlincomb(v1,c1,v2,c2,v3,c3);
else
temp = v1 .* c1 + v2 .* c2 + v3 .* c3;
end
global outpu;
outpu=temp;
X=9;
val=0.52789;
global result;
if exist('imlincomb')
result = imlincomb(val, pet, 1-val, temp);
else
result = val .* pet + (1-val) .* temp;
end
axes(handles.axes5);
%place image onto the axes
image(temp);
%remove the axis tick marks
axis off
axes(handles.axes6);
%place image onto the axes
image(result);
%remove the axis tick marks
axis off
% Hint: get(hObject,'Value') returns toggle state of togglebutton1
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
global result;
figure,imshow(result),title('Figure can be adjusted and printed using the print option in the toolbar');
print -f1
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
global ss;
var=0;
if(ss==0 && var==0)
set(handles.pushbutton7,'String','Help')
set(handles.text9,'Visible','off')
set(handles.text10,'Visible','off')
set(handles.text11,'Visible','off')
ss=1;
var=2;
end
if(ss==1 && var==0)
set(handles.pushbutton7,'String','Hide')
set(handles.text9,'Visible','on')
set(handles.text10,'Visible','on')
set(handles.text11,'Visible','on')
ss=0;
var=2;
end
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
exit
% handles structure with handles and user data (see GUIDATA)
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function edit3_Callback(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit3 as text
% str2double(get(hObject,'String')) returns contents of edit3 as a double
% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function edit4_Callback(hObject, eventdata, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit4 as text
% str2double(get(hObject,'String')) returns contents of edit4 as a double
% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function edit5_Callback(hObject, eventdata, handles)
% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit5 as text
% str2double(get(hObject,'String')) returns contents of edit5 as a double
% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton10 (see GCBO)
% strA and strB is the source images and strF is the fusion result
global output;
global outpu;
global result;
% model parameters
rgb_img=output;
I = .2989*rgb_img(:,:,1)...
+.5870*rgb_img(:,:,2)...
+.1140*rgb_img(:,:,3);
min(I(:))
ans =0
max(I(:))
ans = 255
colormap(gray(256));
image_out2=I;
rgb_img=outpu;
I = .2989*rgb_img(:,:,1)...
+.5870*rgb_img(:,:,2)...
+.1140*rgb_img(:,:,3);
min(I(:))
ans =0
max(I(:))
ans = 255
colormap(gray(256));
image_out1=I;
rgb_img=result;
I = .2989*rgb_img(:,:,1)...
+.5870*rgb_img(:,:,2)...
+.1140*rgb_img(:,:,3);
min(I(:))
ans =0
max(I(:))
ans = 255
colormap(gray(256));
image_out3=I;
L=1; Tg=0.9994;kg=-15;Dg=0.5;Ta=0.9879;ka=-22;Da=0.8;
% Sobel Operator
h1=[1 2 1;0 0 0;-1 -2 -1]; h2=[0 1 2;-1 0 1;-2 -1 0]; h3=[-1 0 1;-2 0 2;-1 0 1];
% if y is the response to h1 and x is the response to h3;
% then the intensity is sqrt(x^2+y^2) and orientation is arctan(y/x);
pA = image_out1;
%pA = double(pA);
pB = image_out2;
%pB = double(pB);
pF = image_out3;
%pF = double(pF);
SAx = conv2(pA,h3,'same'); SAy = conv2(pA,h1,'same');
gA = sqrt(SAx.^2 + SAy.^2);
[M,N] = size(SAx); aA = zeros(M,N);
for i=1:M
for j=1:N
if ( SAx(i,j) == 0 ) aA(i,j) = pi/2;
else
aA(i,j) = atan(SAy(i,j)/SAx(i,j));
end
end
end
SBx = conv2(pB,h3,'same'); SBy = conv2(pB,h1,'same');
gB = sqrt(SBx.^2 + SBy.^2);
[M,N] = size(SBx); aB = zeros(M,N);
for i=1:M
for j=1:N
if ( SBx(i,j) == 0 ) aB(i,j) = pi/2;
else
aB(i,j) = atan(SBy(i,j)/SBx(i,j));
end
end
end
SFx = conv2(pF,h3,'same'); SFy = conv2(pF,h1,'same');
gF = sqrt(SFx.^2 + SFy.^2);
[M,N] = size(SAx); aF = zeros(M,N);
for i=1:M
for j=1:N
if ( SFx(i,j) == 0 ) aF(i,j) = pi/2;
else
aF(i,j) = atan(SFy(i,j)/SFx(i,j));
end
end
end
% the relative strength and orientation value of GAF,GBF and AAF,ABF;
GAF = zeros(M,N); AAF = zeros(M,N); QgAF = zeros(M,N); QaAF = zeros(M,N); QAF = zeros(M,N);
for i=1:M
for j=1:N
if ( gA(i,j) > gF(i,j)) GAF(i,j) = gF(i,j)/gA(i,j);
else
if ( gA(i,j) == gF(i,j) ) GAF(i,j) = gF(i,j);
else
GAF(i,j) = gA(i,j) / gF(i,j);
end
end
AAF(i,j) = 1 - abs(aA(i,j)-aF(i,j))/(pi/2);
QgAF(i,j) = Tg / (1 + exp(kg*( GAF(i,j) - Dg )));
QaAF(i,j) = Ta / (1 + exp(ka*( AAF(i,j) - Da )));
QAF(i,j) = QgAF(i,j) * QaAF(i,j);
end
end
GBF = zeros(M,N); ABF = zeros(M,N); QgBF = zeros(M,N); QaBF = zeros(M,N); QBF = zeros(M,N);
for i=1:M
for j=1:N
if ( gB(i,j) > gF(i,j)) GBF(i,j) = gF(i,j)/gB(i,j);
else
if ( gB(i,j) == gF(i,j) ) GBF(i,j) = gF(i,j);
else
GBF(i,j) = gB(i,j) / gF(i,j);
end
end
ABF(i,j) = 1 - abs(aB(i,j)-aF(i,j))/(pi/2);
QgBF(i,j) = Tg / (1 + exp(kg*( GBF(i,j) - Dg )));
QaBF(i,j) = Ta / (1 + exp(ka*( ABF(i,j) - Da )));
QBF(i,j) = QgBF(i,j) * QaBF(i,j);
end
end
% compute the QABF
deno = sum(sum( gA + gB ));
nume = sum(sum( QAF.*gA + QBF.*gB ));
ou = nume / deno;
set(handles.edit5,'String',ou)
% handles structure with handles and user data (see GUIDATA)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -