📄 image_mva_0.m
字号:
handles.scores=scores;
handles.loads=loads;
close(h)
H.Position=[633 109 274 414];
figure(H)
subplot(2,1,1)
iptsetpref('ImshowAxesVisible', 'on')
imshow(scores(:,:,1),[min(min(scores(:,:,1))) max(max(scores(:,:,1)))])
colormap(gray)
subplot(2,1,2)
plot(loads(:,1))
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function pca_disp_N_CreateFcn(hObject, eventdata, handles)
% hObject handle to pca_disp_N (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 pca_disp_N_Callback(hObject, eventdata, handles)
% hObject handle to pca_disp_N (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 pca_disp_N as text
% str2double(get(hObject,'String')) returns contents of pca_disp_N as a double
Icomp=str2double(get(hObject,'String')) ;
handles.Icomp=Icomp;
guidata(hObject,handles)
% --- Executes on button press in pca_display.
function pca_display_Callback(hObject, eventdata, handles)
% hObject handle to pca_display (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
scores=handles.scores;
loads=handles.loads;
Icomp=handles.Icomp;
H.Position=[633 109 274 414];
figure(H)
subplot(2,1,1)
iptsetpref('ImshowAxesVisible', 'on')
imshow(scores(:,:,Icomp),[min(min(scores(:,:,Icomp))) max(max(scores(:,:,Icomp)))])
subplot(2,1,2)
plot(loads(:,Icomp))
% --------------------------------------------------------------------
function save_pca_Callback(hObject, eventdata, handles)
% hObject handle to save_pca (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
datapath = uigetdir;
cd(datapath)
scores=handles.scores;
loads=handles.loads;
image=handles.image;
[filename, pathname] = uiputfile('*.mat', 'Save results as');
save(filename)
% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_3_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function normalize_Callback(hObject, eventdata, handles)
% hObject handle to normalize (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
data=handles.image;
N=handles.N;
[n,p,q]=size(data);
[a,rect]=imcrop(uint8(data(:,:,N)));
for i=1:q;
image_crop(:,:,i)=imcrop(data(:,:,i),rect);
end
axes(handles.axes1)
iptsetpref('ImshowAxesVisible', 'on')
imshow(image_crop(:,:,N),[min(min(image_crop(:,:,N))) max(max(image_crop(:,:,N)))])
handles.image=image_crop;
guidata(hObject,handles)
% --------------------------------------------------------------------
function Untitled_2_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function smooth_Callback(hObject, eventdata, handles)
% hObject handle to smooth (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
data=handles.image;
[n,p,q]=size(data);
type=questdlg('How do you want resize the image?','Image resize','Increase', 'Shrink ', 'Increase');
if type=='Increase'
N=inputdlg('Enter N times to increase the image');
N=str2double(N);
for i=1:q;
data_res(:,:,i) = imresize(data(:,:,i),N,'bicubic');
end
else
N=inputdlg('Enter N times to shrink the image');
N=str2double(N);
for i=1:q;
data_res(:,:,i) = imresize(data(:,:,i),1/N,'bicubic');
end
end
axes(handles.axes1)
iptsetpref('ImshowAxesVisible', 'on')
imshow(data_res(:,:,1),[min(min(data_res(:,:,1))) max(max(data_res(:,:,1)))])
handles.image=data_res;
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function simp_N_CreateFcn(hObject, eventdata, handles)
% hObject handle to simp_N (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 simp_N_Callback(hObject, eventdata, handles)
% hObject handle to simp_N (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 simp_N as text
% str2double(get(hObject,'String')) returns contents of simp_N as a double
Nsimp=str2double(get(hObject,'String'));
handles.der=0;
handles.simp_N=Nsimp;
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function simp_offset_CreateFcn(hObject, eventdata, handles)
% hObject handle to simp_offset (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 simp_offset_Callback(hObject, eventdata, handles)
% hObject handle to simp_offset (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 simp_offset as text
% str2double(get(hObject,'String')) returns contents of simp_offset as a double
offset=str2double(get(hObject,'String')) ;
handles.offset=offset;
guidata(hObject,handles)
% --- Executes on button press in simpl_2nd.
function simpl_2nd_Callback(hObject, eventdata, handles)
% hObject handle to simpl_2nd (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of simpl_2nd
der=get(hObject,'Value');
handles.der=der;
guidata(hObject,handles)
% --- Executes on button press in simplisma_main.
function simplisma_main_Callback(hObject, eventdata, handles)
% hObject handle to simplisma_main (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
offset=handles.offset;
Nsimp=handles.simp_N;
der=handles.der;
images=handles.image;
[n,m,p]=size(images);
data=reshape(images,[n*m p]);
if der==0
[purspec,purint,purity_spec]=simplisma(data,[1:p], offset,Nsimp);
else
data2=invder(data);
[purspec,purint,purity_spec]=simplisma(data,[1:p], offset,Nsimp,data2);
end
pur_images=reshape(purint,[n m Nsimp]);
pur_int=purspec';
H.Position=[633 109 274 414];
figure(H)
subplot(2,1,1)
iptsetpref('ImshowAxesVisible', 'on')
imshow(pur_images(:,:,1),[min(min(pur_images(:,:,1))) max(max(pur_images(:,:,1)))])
subplot(2,1,2)
plot(pur_int(:,1))
handles.pur_images=pur_images;
handles.pur_int=pur_int;
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function simp_disp_N_CreateFcn(hObject, eventdata, handles)
% hObject handle to simp_disp_N (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 simp_disp_N_Callback(hObject, eventdata, handles)
% hObject handle to simp_disp_N (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 simp_disp_N as text
% str2double(get(hObject,'String')) returns contents of simp_disp_N as a double
Isimp=str2double(get(hObject,'String')) ;
handles.Isimp=Isimp;
guidata(hObject,handles)
% --- Executes on button press in simp_disp.
function simp_disp_Callback(hObject, eventdata, handles)
% hObject handle to simp_disp (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
pur_images=handles.pur_images;
pur_int=handles.pur_int;
Isimp=handles.Isimp;
H.Position=[633 109 274 414];
figure(H)
subplot(2,1,1)
iptsetpref('ImshowAxesVisible', 'on')
imshow(pur_images(:,:,Isimp),[min(min(pur_images(:,:,Isimp))) max(max(pur_images(:,:,Isimp)))])
subplot(2,1,2)
plot(pur_int(:,Isimp))
% --------------------------------------------------------------------
function save_simpl_Callback(hObject, eventdata, handles)
% hObject handle to save_simpl (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
pur_images=handles.pur_images;
pur_int=handles.pur_int;
images=handles.image;
datapath = uigetdir;
cd(datapath)
[filename, pathname] = uiputfile('*.mat', 'Save results as');
save(filename)
% --- Executes during object creation, after setting all properties.
function edit8_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit8 (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 edit8_Callback(hObject, eventdata, handles)
% hObject handle to edit8 (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 edit8 as text
% str2double(get(hObject,'String')) returns contents of edit8 as a double
% --- Executes on button press in mcr_main.
function mcr_main_Callback(hObject, eventdata, handles)
% hObject handle to mcr_main (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
images=handles.image;
[n,m,p]=size(images);
data=reshape(images,[n*m p]);
opt=questdlg('Which intialization you want to use?','MCR','Random ', 'PCA ', 'Simplisma', 'Random ');
if opt=='Random ';
N=inputdlg('Enter the number of components');
Nmcr=str2double(N);
c0=rand(p,Nmcr);
elseif opt=='PCA '
loads=handles.loads;
c0=loads;
else
pur_int=handles.pur_int;
c0=pur_int;
end
opt=questdlg('Do you want to apply nonnegativity to Concentrations?','MCR','Yes', 'No ', 'Yes');
if opt=='Yes'
opt=questdlg('It may take very long time to calculate! Do you still want to apply nonnegativity?','MCR','Yes', 'No ', 'Yes');
if opt=='Yes'
ccon = 2;
else
ccon=0;
end
else
ccon = 0;
end
opt=questdlg('Do you want to apply nonnegativity to Spectra?','MCR','Yes', 'No ', 'Yes');
if opt=='Yes'
opt=questdlg('It may take very long time to calculate! Do you still want to apply nonnegativity?','MCR','Yes', 'No ', 'Yes');
if opt=='Yes'
scon = 2;
else
scon = 0;
end
else
scon = 0;
end
h = waitbar(0,'Please wait while MCR is performed...');
[c,s] = mcr(data',c0,ccon,scon);
close(h)
[n1,p]=size(s);
mcr_images=reshape(s',[n m n1]);
mcr_int=c;
H.Position=[633 109 274 414];
figure(H)
subplot(2,1,1)
iptsetpref('ImshowAxesVisible', 'on')
imshow(mcr_images(:,:,1),[min(min(mcr_images(:,:,1))) max(max(mcr_images(:,:,1)))])
subplot(2,1,2)
plot(mcr_int(:,1))
handles.mcr_images=mcr_images;
handles.mcr_int=mcr_int;
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function mcr_disp_N_CreateFcn(hObject, eventdata, handles)
% hObject handle to mcr_disp_N (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 mcr_disp_N_Callback(hObject, eventdata, handles)
% hObject handle to mcr_disp_N (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 mcr_disp_N as text
% str2double(get(hObject,'String')) returns contents of mcr_disp_N as a double
Imcr=str2double(get(hObject,'String')) ;
handles.Imcr=Imcr;
guidata(hObject,handles)
% --- Executes on button press in mcr_disp.
function mcr_disp_Callback(hObject, eventdata, handles)
% hObject handle to mcr_disp (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
mcr_images=handles.mcr_images;
mcr_int=handles.mcr_int;
Imcr=handles.Imcr;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -