Added source files
BIN
src/Resources/DigImCorr_resources/icon_16.png
Normal file
|
After Width: | Height: | Size: 955 B |
BIN
src/Resources/DigImCorr_resources/icon_24.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
src/Resources/DigImCorr_resources/icon_48.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
src/Resources/DigImCorrtt_resources/icon_16.png
Normal file
|
After Width: | Height: | Size: 972 B |
BIN
src/Resources/DigImCorrtt_resources/icon_24.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
src/Resources/DigImCorrtt_resources/icon_48.png
Normal file
|
After Width: | Height: | Size: 7.3 KiB |
810
src/dic/Beginner4.m
Normal file
@@ -0,0 +1,810 @@
|
|||||||
|
function varargout = Beginner4(varargin)
|
||||||
|
% BEGINNER4 MATLAB code for Beginner4.fig
|
||||||
|
% BEGINNER4, by itself, creates a new BEGINNER4 or raises the existing
|
||||||
|
% singleton*.
|
||||||
|
%
|
||||||
|
% H = BEGINNER4 returns the handle to a new BEGINNER4 or the handle to
|
||||||
|
% the existing singleton*.
|
||||||
|
%
|
||||||
|
% BEGINNER4('CALLBACK',hObject,eventData,handles,...) calls the local
|
||||||
|
% function named CALLBACK in BEGINNER4.M with the given input arguments.
|
||||||
|
%
|
||||||
|
% BEGINNER4('Property','Value',...) creates a new BEGINNER4 or raises
|
||||||
|
% the existing singleton*. Starting from the left, property value pairs are
|
||||||
|
% applied to the GUI before Beginner4_OpeningFcn gets called. An
|
||||||
|
% unrecognized property name or invalid value makes property application
|
||||||
|
% stop. All inputs are passed to Beginner4_OpeningFcn via varargin.
|
||||||
|
%
|
||||||
|
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
|
||||||
|
% instance to run (singleton)".
|
||||||
|
%
|
||||||
|
% See also: GUIDE, GUIDATA, GUIHANDLES
|
||||||
|
|
||||||
|
% Edit the above text to modify the response to help Beginner4
|
||||||
|
|
||||||
|
% Last Modified by GUIDE v2.5 23-May-2018 01:44:50
|
||||||
|
|
||||||
|
% Begin initialization code - DO NOT EDIT
|
||||||
|
gui_Singleton = 1;
|
||||||
|
gui_State = struct('gui_Name', mfilename, ...
|
||||||
|
'gui_Singleton', gui_Singleton, ...
|
||||||
|
'gui_OpeningFcn', @Beginner4_OpeningFcn, ...
|
||||||
|
'gui_OutputFcn', @Beginner4_OutputFcn, ...
|
||||||
|
'gui_LayoutFcn', [] , ...
|
||||||
|
'gui_Callback', []);
|
||||||
|
if nargin && ischar(varargin{1})
|
||||||
|
gui_State.gui_Callback = str2func(varargin{1});
|
||||||
|
end
|
||||||
|
|
||||||
|
if nargout
|
||||||
|
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
|
||||||
|
else
|
||||||
|
gui_mainfcn(gui_State, varargin{:});
|
||||||
|
end
|
||||||
|
% End initialization code - DO NOT EDIT
|
||||||
|
|
||||||
|
% --- Executes just before Beginner4 is made visible.
|
||||||
|
function Beginner4_OpeningFcn(hObject, eventdata, handles, varargin)
|
||||||
|
% This function has no output args, see OutputFcn.
|
||||||
|
% hObject handle to figure
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
% varargin command line arguments to Beginner4 (see VARARGIN)
|
||||||
|
|
||||||
|
% Choose default command line output for Beginner4
|
||||||
|
handles.output = hObject;
|
||||||
|
handles.Load_RADIO ='Images';
|
||||||
|
axes(handles.axes7);cla;imshow((imread('lines.png')),[]);
|
||||||
|
axes(handles.axes8);cla;imshow(imread('Shan_Logo1.jpg'),[]);
|
||||||
|
axes(handles.axes6);cla;imshow(imread('iisc_logo.png'),[]);
|
||||||
|
|
||||||
|
seting_buttons_state(hObject, eventdata, handles,0)
|
||||||
|
set(handles.push_start_DIC, 'Enable','off');
|
||||||
|
set(handles.Status_check,'String','In pixels');
|
||||||
|
% set(handles.txt_ref, 'String','Hi');
|
||||||
|
|
||||||
|
handles.image_crop =0;
|
||||||
|
|
||||||
|
% show_the_image1()
|
||||||
|
% handles.aarea = 'Default';
|
||||||
|
% handles.filename_RADIO ='DEFORMED';
|
||||||
|
|
||||||
|
handles.val_overlap= 0.5;
|
||||||
|
handles.val_windowsize_x = 64;
|
||||||
|
handles.val_windowsize_y = 64;
|
||||||
|
handles.val_dicmethod = 'method_2';
|
||||||
|
% handles.flg1= 0;
|
||||||
|
handles.displayData = 'U';
|
||||||
|
handles.scal =1;
|
||||||
|
handles.val_scal=1;
|
||||||
|
handles.Logfile =1;
|
||||||
|
handles.select_resolution=0;
|
||||||
|
|
||||||
|
axes(handles.axes3);cla;imshow(imread('p1.png') ,[]);
|
||||||
|
set(handles.checkbox1_LogFile,'Value',1);
|
||||||
|
seting_buttons_state(hObject, eventdata, handles,0)
|
||||||
|
|
||||||
|
% set(handles.TEXT2,'String','In pixels');
|
||||||
|
% set(handles.Status_check,'String','In pixels');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
% Update handles structurelogfile
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
|
||||||
|
% UIWAIT makes Beginner4 wait for user response (see UIRESUME)
|
||||||
|
% uiwait(handles.figure1);
|
||||||
|
|
||||||
|
|
||||||
|
% --- Outputs from this function are returned to the command line.
|
||||||
|
function varargout = Beginner4_OutputFcn(hObject, eventdata, handles)
|
||||||
|
% varargout cell array for returning output args (see VARARGOUT);
|
||||||
|
% hObject handle to figure
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
% Get default command line output from handles structure
|
||||||
|
varargout{1} = handles.output;
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on button press in LogFile_check.
|
||||||
|
function LogFile_check_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to LogFile_check (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 LogFile_check
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on button press in push_load_reference.
|
||||||
|
function push_load_reference_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to push_load_reference (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 push_load_deformed.
|
||||||
|
function push_load_deformed_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to push_load_deformed (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 push_startDIC.
|
||||||
|
function push_startDIC_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to push_startDIC (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 pushbutton5.
|
||||||
|
function pushbutton5_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to pushbutton5 (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 checkbox1_LogFile.
|
||||||
|
function checkbox1_LogFile_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to checkbox1_LogFile (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 checkbox1_LogFile
|
||||||
|
handles.Logfile= get(hObject,'Value');
|
||||||
|
guidata(hObject, handles)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on button press in push_start_DIC.
|
||||||
|
function push_start_DIC_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to push_start_DIC (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
Files = dir(handles.path);
|
||||||
|
% tmp=length(Files)
|
||||||
|
[~,Ref_name,EXT] = fileparts(handles.val_filename_1);
|
||||||
|
tmpp=0;
|
||||||
|
|
||||||
|
|
||||||
|
if iscell(handles.def_name)==1
|
||||||
|
tmpp = numel(handles.def_name);
|
||||||
|
FFiles=handles.def_name;
|
||||||
|
else
|
||||||
|
tmpp = 1;
|
||||||
|
FFiles={handles.def_name};
|
||||||
|
end
|
||||||
|
frame_no=tmpp;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
try
|
||||||
|
[user_response, destination ] = gui_confirm_DICstart2(tmpp,handles.path);
|
||||||
|
catch
|
||||||
|
user_response='NO';
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
switch lower(user_response)
|
||||||
|
case 'no'
|
||||||
|
% take no action
|
||||||
|
case 'yes'
|
||||||
|
seting_buttons_state11(hObject, eventdata, handles,0)
|
||||||
|
pause(0.1)
|
||||||
|
% s1= handles.val_filename_1;
|
||||||
|
% s=strfind(s1,'.');s1(s(end)+1:length(s1)-1);
|
||||||
|
%
|
||||||
|
imr11 = imread(handles.val_filename_1);
|
||||||
|
IM1 = imr11;
|
||||||
|
imr1=preset_image(imr11);
|
||||||
|
flies = {};
|
||||||
|
M=[];
|
||||||
|
|
||||||
|
|
||||||
|
hhhh = waitbar(0,'Please wait...');
|
||||||
|
|
||||||
|
|
||||||
|
DATA=[];
|
||||||
|
kkk=0;
|
||||||
|
for k =1:tmpp
|
||||||
|
|
||||||
|
waitbar(k/length(Files),hhhh);
|
||||||
|
|
||||||
|
FileNames = FFiles{k};
|
||||||
|
file = strcat(handles.path, FFiles{k});
|
||||||
|
DefaultORcrop='Full Frame';
|
||||||
|
if strcmp(file, handles.val_filename_1)==0
|
||||||
|
|
||||||
|
|
||||||
|
imr22 = imread(file);
|
||||||
|
imr2=preset_image(imr22);
|
||||||
|
DefaultORcrop='Full Frame';
|
||||||
|
|
||||||
|
if handles.image_crop ==1
|
||||||
|
DefaultORcrop='Crop';
|
||||||
|
yD= handles.Cordinates;
|
||||||
|
im1 = imr1( yD(2):yD(2)+yD(4),yD(1):yD(1)+yD(3),:);
|
||||||
|
im2 = imr2( yD(2):yD(2)+yD(4),yD(1):yD(1)+yD(3),:);
|
||||||
|
IM = IM1( yD(2):yD(2)+yD(4),yD(1):yD(1)+yD(3),:);
|
||||||
|
|
||||||
|
else handles.image_crop ==0;
|
||||||
|
im1 = imr1;
|
||||||
|
im2 = imr2;
|
||||||
|
IM = IM1;
|
||||||
|
end
|
||||||
|
|
||||||
|
windowsize_x = handles.val_windowsize_x;
|
||||||
|
windowsize_y= handles.val_windowsize_y;
|
||||||
|
overlap= handles.val_overlap;
|
||||||
|
iu_max =32;
|
||||||
|
iv_max =32;
|
||||||
|
dt = 1;
|
||||||
|
dic_type = handles.val_dicmethod;
|
||||||
|
i_recur = 1;
|
||||||
|
i_plot=0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[MM, AA]=DIC_Data_check_Beginner3(im1, im2, windowsize_x, windowsize_y, overlap, iu_max, iv_max,...
|
||||||
|
handles.scal,FileNames, IM,destination, handles.val_dicmethod,handles.select_resolution, handles.Cordinates, IM1);
|
||||||
|
|
||||||
|
|
||||||
|
% figure,imshow(im2,[]), title(strcat('Vector Field:-:', FileNames))
|
||||||
|
else
|
||||||
|
|
||||||
|
MM = [0 0 0 0 0 0 0 0];
|
||||||
|
dic_type = 'Not-Procssed, Same Image';
|
||||||
|
windowsize_x = 0;
|
||||||
|
overlap=0;
|
||||||
|
end
|
||||||
|
|
||||||
|
flies{k} = FileNames;
|
||||||
|
|
||||||
|
M=[M;MM];
|
||||||
|
AA.name=FileNames;
|
||||||
|
DATA{k}=AA;
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
% % save strcat(destination, 'DATA') DATA;
|
||||||
|
|
||||||
|
|
||||||
|
des=strcat(destination,'\DATA');
|
||||||
|
save(des,'DATA')
|
||||||
|
|
||||||
|
|
||||||
|
if (handles.Logfile==1), myLogfile(destination, 'Image',frame_no,DefaultORcrop, Ref_name, dic_type, ...
|
||||||
|
windowsize_x,overlap); end
|
||||||
|
|
||||||
|
M = round(M*1000)/1000;
|
||||||
|
seting_buttons_state11(hObject, eventdata, handles,1)
|
||||||
|
try
|
||||||
|
close(hhhh)
|
||||||
|
catch
|
||||||
|
end
|
||||||
|
|
||||||
|
Mean_U = M(:,1);
|
||||||
|
Mean_V = M(:,2);
|
||||||
|
MIN_U = M(:,3);
|
||||||
|
MAX_U = M(:,4);
|
||||||
|
MIN_V = M(:,5);
|
||||||
|
MAX_V = M(:,6);
|
||||||
|
StdDev_U = M(:,7);
|
||||||
|
StdDev_V = M(:,8);
|
||||||
|
|
||||||
|
|
||||||
|
% Tabb11 = table(flies', Mean_U, Mean_V, StdDev_U, StdDev_V );
|
||||||
|
Tabb11 = table(flies', Mean_U, Mean_V, MIN_U, MAX_U, MIN_V, MAX_V,StdDev_U, StdDev_V );
|
||||||
|
writetable(Tabb11,strcat(destination, '\result11_summary' ))
|
||||||
|
|
||||||
|
end
|
||||||
|
guidata(hObject, handles)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on button press in pushbutton9.
|
||||||
|
function pushbutton9_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to pushbutton9 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
open('Help_DIC_BJ2.pdf');
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on button press in push_reference.
|
||||||
|
function push_reference_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to push_reference (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
Sw= handles.Load_RADIO;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
switch Sw
|
||||||
|
|
||||||
|
case {'Images'}
|
||||||
|
|
||||||
|
files= uigetfile_with_preview2();
|
||||||
|
|
||||||
|
if ~strcmp(files,'')
|
||||||
|
|
||||||
|
seting_buttons(hObject, eventdata, handles);
|
||||||
|
seting_buttons_state(hObject, eventdata, handles,0)
|
||||||
|
set(handles.push_deformed, 'Enable','on');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
% % % seting_buttons_state(hObject, eventdata, handles,1)
|
||||||
|
s=files; s=s(1:max(find(s=='\'))); pathname=s;
|
||||||
|
s=files; s=s(max(find(s=='\'))+1:end); filename=s;
|
||||||
|
handles.val_filename_1 = strcat(pathname, filename);
|
||||||
|
|
||||||
|
|
||||||
|
set(handles.txt_ref, 'String','filename');
|
||||||
|
guidata(hObject, handles);
|
||||||
|
% set(handles.push_reference,'String',filename);
|
||||||
|
set(handles.txt_ref, 'String', filename );
|
||||||
|
|
||||||
|
tmp = imread(handles.val_filename_1);
|
||||||
|
|
||||||
|
handles.val_file_1 = (tmp);
|
||||||
|
[~,~,EXT] = fileparts(handles.val_filename_1);
|
||||||
|
handles.EXT=EXT;
|
||||||
|
handles.path= pathname;
|
||||||
|
handles.Cordinates = [1 1 size(handles.val_file_1,2) size(handles.val_file_1,1)];
|
||||||
|
|
||||||
|
handles.Scal=1;
|
||||||
|
set(handles.Status_check ,'String',' ');
|
||||||
|
handles.image_crop =0;
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
|
||||||
|
files= dir(pathname);
|
||||||
|
|
||||||
|
|
||||||
|
axes(handles.axes3);cla;imshow(handles.val_file_1 ,[]);
|
||||||
|
|
||||||
|
set(handles.number_image,'String','');
|
||||||
|
end
|
||||||
|
|
||||||
|
% end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
case {'Video'}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
otherwise
|
||||||
|
disp('Unknown method')
|
||||||
|
|
||||||
|
end
|
||||||
|
set(handles.push_start_DIC, 'Enable','off');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on button press in push_deformed.
|
||||||
|
function push_deformed_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to push_deformed (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
% % % Files = dir(handles.path);
|
||||||
|
% tmp=length(Files)
|
||||||
|
try
|
||||||
|
[~,Ref_name,EXT] = fileparts(handles.val_filename_1);
|
||||||
|
catch
|
||||||
|
EXT = 0;
|
||||||
|
end
|
||||||
|
% % % % % % % % % % % % % tmp=0;
|
||||||
|
|
||||||
|
|
||||||
|
[filename_def, pathname_def, filterindex_def] = uigetfile( ...
|
||||||
|
{strcat('*', EXT), strcat(EXT,'-files') }, ...
|
||||||
|
'MultiSelect', 'on', 'Selet the DEFORMED images', handles.path);
|
||||||
|
|
||||||
|
handles.def_name= filename_def;
|
||||||
|
handles.def_path= pathname_def;
|
||||||
|
handles.correctSelect= filterindex_def;
|
||||||
|
% % set(handles.push_deformed,'String',filename_def(end));
|
||||||
|
im1=imread(handles.val_filename_1);
|
||||||
|
|
||||||
|
if filterindex_def==1
|
||||||
|
seting_buttons_state(hObject, eventdata, handles,1)
|
||||||
|
if iscell(filename_def)==1
|
||||||
|
tmp = strcat(num2str(numel(filename_def)), 'files selected');
|
||||||
|
% set(handles.push_deformed,'String',filename_def{end});
|
||||||
|
im2 = imread(strcat(pathname_def, filename_def{end}));
|
||||||
|
axes(handles.axes3);cla;imshow(imread(strcat(pathname_def,filename_def{end})) ,[]);
|
||||||
|
set(handles.push_start_DIC, 'Enable','on');
|
||||||
|
else
|
||||||
|
tmp = strcat('1', 'files selected');
|
||||||
|
% set(handles.push_deformed,'String',filename_def);
|
||||||
|
im2 = imread(strcat(pathname_def, filename_def));
|
||||||
|
axes(handles.axes3);cla;imshow(imread(strcat(pathname_def,filename_def)) ,[]);
|
||||||
|
set(handles.push_start_DIC, 'Enable','on');
|
||||||
|
end
|
||||||
|
set(handles.number_image,'String',tmp);
|
||||||
|
|
||||||
|
if ~(isequal(size(im1),size(im2)))
|
||||||
|
gui_DIC_sizeCheck1('Title','ERROR');
|
||||||
|
tmp = strcat('0', 'files selected');
|
||||||
|
set(handles.number_image,'String',tmp);
|
||||||
|
set(handles.push_start_DIC, 'Enable','off');
|
||||||
|
seting_buttons_state(hObject, eventdata, handles,0);
|
||||||
|
set(handles.push_deformed, 'Enable','on');
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
else
|
||||||
|
tmp = strcat('0', 'files selected');
|
||||||
|
set(handles.number_image,'String',tmp);
|
||||||
|
set(handles.push_start_DIC, 'Enable','off');
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
seting_buttons(hObject, eventdata, handles);
|
||||||
|
|
||||||
|
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes when selected object is changed in uibuttongroup5.
|
||||||
|
function uibuttongroup5_SelectionChangedFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to the selected object in uibuttongroup5
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
c= get(hObject,'String');
|
||||||
|
%%%%%%%%%%%seting_buttons_state(hObject, eventdata, handles,0);
|
||||||
|
% set(handles.push_reference,'String','Reference');
|
||||||
|
% set(handles.push_deformed,'String','Deformed');
|
||||||
|
|
||||||
|
seting_buttons_state(hObject, eventdata, handles,0);
|
||||||
|
|
||||||
|
switch c
|
||||||
|
|
||||||
|
case {'Images'}
|
||||||
|
handles.Load_RADIO ='Images';
|
||||||
|
% guidata(hObject, handles);
|
||||||
|
|
||||||
|
case 'Video'
|
||||||
|
handles.Load_RADIO ='Video';
|
||||||
|
|
||||||
|
EXT='avi';
|
||||||
|
[filename_def, pathname_def, filterindex_def] = uigetfile( ...
|
||||||
|
{strcat('*', EXT), strcat(EXT,'-files') });
|
||||||
|
|
||||||
|
|
||||||
|
if filterindex_def==1
|
||||||
|
% seting_buttons_state(hObject, eventdata, handles,1)
|
||||||
|
% set(handles.number_image,'String',tmp);
|
||||||
|
|
||||||
|
mkdir(pathname_def,'images101');
|
||||||
|
|
||||||
|
vdo= VideoReader(strcat(pathname_def, '\' ,filename_def));
|
||||||
|
ii = 1;
|
||||||
|
|
||||||
|
while hasFrame(vdo)
|
||||||
|
img = readFrame(vdo);
|
||||||
|
filename = [sprintf('%03d',ii) '.jpg'];
|
||||||
|
fullname = fullfile(pathname_def, 'images101',filename);
|
||||||
|
imwrite(img,fullname) % Write out to a JPEG file (img1.jpg, img2.jpg, etc.)
|
||||||
|
ii = ii+1;
|
||||||
|
end
|
||||||
|
|
||||||
|
handles.path= pathname_def;
|
||||||
|
|
||||||
|
handles.Load_RADIO ='Images';
|
||||||
|
guidata(hObject, handles)
|
||||||
|
|
||||||
|
else
|
||||||
|
handles.Load_RADIO ='Images';
|
||||||
|
seting_buttons_state(hObject, eventdata, handles,0)
|
||||||
|
set(handles.radiobutton14, 'Value',0);
|
||||||
|
set(handles.radiobutton13, 'Value',1);
|
||||||
|
|
||||||
|
guidata(hObject, handles)
|
||||||
|
% tmp = strcat('0', 'files selected');
|
||||||
|
% set(handles.number_image,'String',tmp);
|
||||||
|
% set(handles.push_start_DIC, 'Enable','off');
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
% guidata(hObject, handles);
|
||||||
|
otherwise
|
||||||
|
disp('Unknown method')
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
seting_buttons(hObject, eventdata, handles);
|
||||||
|
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function seting_buttons(hObject, eventdata, handles)
|
||||||
|
|
||||||
|
button_list1 =[ handles.radio_scal_full handles.radio_Scal_inpixel ];
|
||||||
|
button_list2 =[ handles.radio_scal_crop handles.radio_Scal_inmicron];
|
||||||
|
set(button_list1, 'Value',1);
|
||||||
|
set(button_list2, 'Value',0);
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
|
||||||
|
function seting_buttons_state11(hObject, eventdata, handles,flg)
|
||||||
|
|
||||||
|
button_list1 =[ handles.radio_scal_full handles.radio_Scal_inpixel handles.push_start_DIC];
|
||||||
|
button_list2 =[ handles.radio_scal_crop handles.radio_Scal_inmicron handles.push_deformed];
|
||||||
|
button_list3 =[handles.push_reference];
|
||||||
|
|
||||||
|
if flg==0
|
||||||
|
set(button_list1, 'Enable','off');
|
||||||
|
set(button_list2, 'Enable','off');
|
||||||
|
set(button_list3, 'Enable','off');end
|
||||||
|
if flg==1
|
||||||
|
set(button_list1, 'Enable','on');
|
||||||
|
set(button_list2, 'Enable','on');
|
||||||
|
set(button_list3, 'Enable','on'); end
|
||||||
|
|
||||||
|
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function seting_buttons_state(hObject, eventdata, handles,flg)
|
||||||
|
|
||||||
|
button_list1 =[ handles.radio_scal_full handles.radio_Scal_inpixel handles.push_start_DIC];
|
||||||
|
button_list2 =[ handles.radio_scal_crop handles.radio_Scal_inmicron handles.push_deformed];
|
||||||
|
|
||||||
|
|
||||||
|
if flg==0
|
||||||
|
set(button_list1, 'Enable','off');
|
||||||
|
set(button_list2, 'Enable','off'); end
|
||||||
|
if flg==1
|
||||||
|
set(button_list1, 'Enable','on');
|
||||||
|
set(button_list2, 'Enable','on'); end
|
||||||
|
|
||||||
|
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on button press in radio_scal_full.
|
||||||
|
function radio_scal_full_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to radio_scal_full (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 radio_scal_full
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on button press in radio_Scal_inmicron.
|
||||||
|
function radio_Scal_inmicron_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to radio_Scal_inmicron (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 radio_Scal_inmicron
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes during object creation, after setting all properties.
|
||||||
|
function number_image_CreateFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to number_image (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles empty - handles not created until after all CreateFcns called
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes when selected object is changed in uibuttongroup6.
|
||||||
|
function uibuttongroup6_SelectionChangedFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to the selected object in uibuttongroup6
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
handles.aarea= get(hObject,'String');
|
||||||
|
% ea= get(hObject,'value')
|
||||||
|
|
||||||
|
|
||||||
|
switch handles.aarea
|
||||||
|
|
||||||
|
case {'Crop'}
|
||||||
|
% handles.val_filename_Crop = imread(handles.val_filename_2);
|
||||||
|
% imtool(handles.val_filename_Crop )
|
||||||
|
handles.image_crop =1;
|
||||||
|
% handles.val_filename_Crop = handles.val_file_1 ; handles.val_filename_1
|
||||||
|
handles.val_filename_Crop = imread(handles.val_filename_1);
|
||||||
|
|
||||||
|
|
||||||
|
[~, yD1 ]= gui_Image_Crop_1(handles.val_filename_Crop);
|
||||||
|
|
||||||
|
if ~isempty(yD1)
|
||||||
|
|
||||||
|
if numel(size(handles.val_filename_Crop))==2
|
||||||
|
s = size(handles.val_filename_Crop); s(3)=1;
|
||||||
|
elseif numel(size(handles.val_filename_Crop))==3
|
||||||
|
s = size(handles.val_filename_Crop);
|
||||||
|
end
|
||||||
|
|
||||||
|
yD = cordinate_filter_mex(yD1, s);
|
||||||
|
|
||||||
|
else yD=[];
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if ~isempty(yD)
|
||||||
|
yD= round(yD);
|
||||||
|
handles.Cordinates=yD;
|
||||||
|
handles.val_filename_Crop = ...
|
||||||
|
handles.val_filename_Crop( yD(2):yD(2)+yD(4),yD(1):yD(1)+yD(3),:);
|
||||||
|
|
||||||
|
axes(handles.axes3);cla;imshow(handles.val_filename_Crop)
|
||||||
|
handles.file_1 = handles.val_file_1;
|
||||||
|
guidata(hObject, handles);
|
||||||
|
else
|
||||||
|
seting_buttons(hObject, eventdata, handles);
|
||||||
|
handles.image_crop =0;
|
||||||
|
guidata(hObject, handles);
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
case {'Full Frame'}
|
||||||
|
handles.image_crop =0;
|
||||||
|
handles.val_file_1 = imread(handles.val_filename_1);
|
||||||
|
axes(handles.axes3);cla;imshow(handles.val_file_1 )
|
||||||
|
handles.file_1 = handles.val_file_1;
|
||||||
|
handles.Cordinates = [1 1 size(handles.val_file_1,2) size(handles.val_file_1,1)];
|
||||||
|
|
||||||
|
guidata(hObject, handles);
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes when selected object is changed in uibuttongroup7.
|
||||||
|
function uibuttongroup7_SelectionChangedFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to the selected object in uibuttongroup7
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
cc= get(hObject,'String');
|
||||||
|
|
||||||
|
switch cc
|
||||||
|
|
||||||
|
case {'In pixels'}
|
||||||
|
handles.Scal=1;
|
||||||
|
% guidata(hObject, handles);
|
||||||
|
tmp3= 'In Pixels';
|
||||||
|
handles.select_resolution=0;
|
||||||
|
guidata(hObject, handles);
|
||||||
|
% set(handles.TEXT2,'String',tmp3);
|
||||||
|
set(handles.Status_check,'String',tmp3);
|
||||||
|
|
||||||
|
case 'In micron'
|
||||||
|
|
||||||
|
try
|
||||||
|
|
||||||
|
% BIKI=gui_set_resolution_3(handles.path,handles.EXT);
|
||||||
|
BIKI=gui_set_resolution_3(1,handles.path,handles.EXT);
|
||||||
|
catch
|
||||||
|
BIKI='aadata';
|
||||||
|
end
|
||||||
|
if ~ strcmp(BIKI,'aadata')
|
||||||
|
BJ = BIKI;
|
||||||
|
if isstr(BIKI), BIKI=str2num(BIKI); end
|
||||||
|
if ~isstr(BJ), BJ=num2str(BJ); end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
tmp3= strcat('1 pixel= ',BJ,' micron');
|
||||||
|
% set(handles.TEXT2,'String',tmp3);
|
||||||
|
set(handles.Status_check ,'String',tmp3);
|
||||||
|
handles.scal=BIKI;
|
||||||
|
handles.select_resolution=1;
|
||||||
|
else
|
||||||
|
% set(handles.Status_check ,'String','NOT Selected', 'DefaultTextColor','green');
|
||||||
|
set(handles.radio_Scal_inmicron, 'Value',0);
|
||||||
|
set(handles.radio_Scal_inpixel, 'Value',1);
|
||||||
|
set(handles.Status_check ,'String','In Pixel', 'DefaultTextColor','green');
|
||||||
|
handles.scal=1;
|
||||||
|
handles.select_resolution=0;
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
% handles.scal=str2num(BIKI)
|
||||||
|
|
||||||
|
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
otherwise
|
||||||
|
disp('Unknown method.')
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
guidata(hObject, handles)
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes during object creation, after setting all properties.
|
||||||
|
function Status_check_CreateFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to Status_check (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles empty - handles not created until after all CreateFcns called
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on button press in radiobutton14.
|
||||||
|
function radiobutton14_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to radiobutton14 (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 radiobutton14
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on button press in radiobutton13.
|
||||||
|
function radiobutton13_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to radiobutton13 (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 radiobutton13
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes during object creation, after setting all properties.
|
||||||
|
function txt_ref_CreateFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to txt_ref (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles empty - handles not created until after all CreateFcns called
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes during object creation, after setting all properties.
|
||||||
|
function text21_CreateFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to text21 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles empty - handles not created until after all CreateFcns called
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes during object creation, after setting all properties.
|
||||||
|
function axes6_CreateFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to axes6 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles empty - handles not created until after all CreateFcns called
|
||||||
|
|
||||||
|
% Hint: place code in OpeningFcn to populate axes6
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes during object creation, after setting all properties.
|
||||||
|
function axes7_CreateFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to axes7 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles empty - handles not created until after all CreateFcns called
|
||||||
|
|
||||||
|
% Hint: place code in OpeningFcn to populate axes7
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes during object creation, after setting all properties.
|
||||||
|
function axes8_CreateFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to axes8 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles empty - handles not created until after all CreateFcns called
|
||||||
|
|
||||||
|
% Hint: place code in OpeningFcn to populate axes8
|
||||||
150
src/dic/DIC_Data_check_Beginner3.m
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
function [M, A]=DIC_Data_check_Beginner3(im1, im2, windowsize_x, windowsize_y, overlap, iu_max, iv_max, inum1, FileNames,IM,Hpath, method, pix_mic, cordinates,IM1)
|
||||||
|
|
||||||
|
flg1= 0;
|
||||||
|
i_recur = 0;
|
||||||
|
|
||||||
|
if pix_mic==0
|
||||||
|
inum =inum1;
|
||||||
|
else
|
||||||
|
inum =inum1*1e-6;
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if (any( size(im1)~=size(im2)) )
|
||||||
|
gui_DIC_sizeCheck1('Title','ERROR');
|
||||||
|
flg1=1;
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if overlap > 0.9
|
||||||
|
gui_DIC_overlapCheck('Title','ERROR');
|
||||||
|
flg1=1;
|
||||||
|
end
|
||||||
|
|
||||||
|
if (flg1==0)
|
||||||
|
|
||||||
|
switch method
|
||||||
|
|
||||||
|
case 'method_1'
|
||||||
|
|
||||||
|
[xi,yi,iu,iv,da]=DIC_mqd5s( im1', im2', windowsize_x, windowsize_y, ...
|
||||||
|
overlap, overlap, iu_max, iv_max, i_recur);
|
||||||
|
|
||||||
|
[iu_ft, iv_ft, iu_ip, iv_ip] = DIC_filter2(iu, iv, 2, 1.5, 2, 0 );
|
||||||
|
[iu_s, iv_s] = DIC_smooth(iu_ip, iv_ip, 2);
|
||||||
|
|
||||||
|
iu_s(isnan(iu_s))=0; iv_s(isnan(iv_s))=0;
|
||||||
|
iu_s = iu_s*inum; iv_s = iv_s*inum; % xi = xi*inum; yi = yi*inum;
|
||||||
|
[x11 y11]= meshgrid(min(xi):max(xi),min(yi):max(yi));
|
||||||
|
[a, b]=meshgrid(yi,xi);
|
||||||
|
F = TriScatteredInterp(b(:),a(:),iu_s(:),'natural');
|
||||||
|
U_inp = F(x11,y11);
|
||||||
|
F = TriScatteredInterp(b(:),a(:),iv_s(:),'natural');
|
||||||
|
V_inp = F(x11,y11);
|
||||||
|
|
||||||
|
M =[mean(iu_s(:)) mean(iv_s(:)) ...
|
||||||
|
min(iu_s(:)) max(iu_s(:)) min(iv_s(:)) max(iv_s(:))...
|
||||||
|
std2(iu_s) std2(iv_s)];
|
||||||
|
|
||||||
|
A.iu_s =iu_s;
|
||||||
|
A.iv_s =iv_s;
|
||||||
|
A.U_inp =U_inp;
|
||||||
|
A.V_inp =V_inp;
|
||||||
|
A.xi = xi;
|
||||||
|
A.yi = yi;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
case 'method_2'
|
||||||
|
|
||||||
|
|
||||||
|
iu_max=windowsize_x; iv_max=windowsize_y;
|
||||||
|
[xi,yi,iu,iv]=DIC_cor5( im1', im2', windowsize_x, windowsize_y, ...
|
||||||
|
overlap, overlap, iu_max, iv_max, i_recur);
|
||||||
|
iu(1,:)=nan; iu(end,:)=nan;iu(:,1)=nan; iu(:,end)=nan;
|
||||||
|
iv(1,:)=nan; iv(end,:)=nan;iv(:,1)=nan; iv(:,end)=nan;
|
||||||
|
|
||||||
|
[iu_ft, iv_ft, iu_ip, iv_ip] = DIC_filter2(iu, iv, 2, 2.0, 2, 0 );
|
||||||
|
[iu_s, iv_s] = DIC_smooth(iu_ip, iv_ip, 2);
|
||||||
|
iv_s=-iv_s;
|
||||||
|
iu_s(isnan(iu_s))=0; iv_s(isnan(iv_s))=0;
|
||||||
|
iu_s = iu_s*inum; iv_s = iv_s*inum; % xi = xi*inum; yi = yi*inum;
|
||||||
|
[x11 y11]= meshgrid(min(xi):max(xi),min(yi):max(yi));
|
||||||
|
[a, b]=meshgrid(yi,xi);
|
||||||
|
|
||||||
|
F = TriScatteredInterp(b(:),a(:),iu_s(:),'natural');
|
||||||
|
U_inp = F(x11,y11);
|
||||||
|
F = TriScatteredInterp(b(:),a(:),iv_s(:),'natural');
|
||||||
|
V_inp = F(x11,y11);
|
||||||
|
|
||||||
|
% M =[mean(iu_s(:)) mean(iv_s(:)) std2(iu_s) std2(iv_s)];
|
||||||
|
|
||||||
|
M =[mean(iu_s(:)) mean(iv_s(:)) ...
|
||||||
|
min(iu_s(:)) max(iu_s(:)) min(iv_s(:)) max(iv_s(:))...
|
||||||
|
std2(iu_s) std2(iv_s)];
|
||||||
|
|
||||||
|
A.iu_s =iu_s;
|
||||||
|
A.iv_s =iv_s;
|
||||||
|
A.U_inp =U_inp;
|
||||||
|
A.V_inp =V_inp;
|
||||||
|
A.xi = xi;
|
||||||
|
A.yi = yi;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
[xx, yy]= meshgrid(xi,yi);
|
||||||
|
fig122=figure; set(fig122, 'Visible', 'off');
|
||||||
|
imshow(IM*0.5),colormap(gray),hold on,
|
||||||
|
quiver (xx,yy, iu_s',-iv_s','g'), axis equal;
|
||||||
|
T=strcat('Vector Field--', FileNames);
|
||||||
|
title(T);
|
||||||
|
TT= strcat(Hpath,'\',T);
|
||||||
|
saveas(gcf, TT);
|
||||||
|
close(fig122)
|
||||||
|
|
||||||
|
if pix_mic==0, titl='[Pixel]';
|
||||||
|
else titl='[m]';
|
||||||
|
end
|
||||||
|
|
||||||
|
%%% if ~max((U_inp(:)))==0; ttm=max(abs(U_inp(:)));else ttm=1e-4; end
|
||||||
|
ttm= max(U_inp(:));
|
||||||
|
fig126=figure; set(fig126, 'Visible', 'off');
|
||||||
|
imagesc(U_inp,[min(U_inp(:)), ttm]),
|
||||||
|
colormap(jet), hcb=colorbar;title(hcb,titl),
|
||||||
|
axis image %Tt=strcat('U--', FileNames); title(Tt);
|
||||||
|
Tt=strcat('Displacement along X, File-', FileNames); title(Tt); xlabel('X-direction (pixels)'), ylabel('Y-direction (pixels)')
|
||||||
|
saveas(gcf, strcat(Hpath,'\',Tt))
|
||||||
|
close(fig126)
|
||||||
|
|
||||||
|
|
||||||
|
image_background2(IM1 , xi,yi,U_inp,cordinates,titl, Tt,Hpath);
|
||||||
|
|
||||||
|
|
||||||
|
%%% if ~max(V_inp(:))==0; ttm=max(abs(V_inp(:)));else ttm=1e-4; end
|
||||||
|
ttm=max(V_inp(:));
|
||||||
|
fig125=figure; set(fig125, 'Visible', 'off');
|
||||||
|
imagesc(V_inp,[min(V_inp(:)), ttm]);
|
||||||
|
colormap(jet), hcb=colorbar;title(hcb,titl);
|
||||||
|
axis image %Tt=strcat('U--', FileNames); title(Tt);
|
||||||
|
Tt=strcat('Displacement along Y, File-', FileNames); title(Tt); xlabel('X-direction (pixels)'), ylabel('Y-direction (pixels)')
|
||||||
|
saveas(gcf, strcat(Hpath,'\',Tt))
|
||||||
|
close(fig125)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
image_background2(IM1 , xi,yi,V_inp,cordinates,titl, Tt, Hpath);
|
||||||
|
|
||||||
|
Tt=strcat('Displacement Magnitude, File-', FileNames);
|
||||||
|
image_background2(IM1 , xi,yi,sqrt(U_inp.^2+V_inp.^2),cordinates,titl, Tt, Hpath);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
81
src/dic/DIC_Linear_Interp_vector3.m
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
|
||||||
|
function[ u_inp1 ] = DIC_Linear_Interp_vector3( ui )
|
||||||
|
%========================================================================
|
||||||
|
|
||||||
|
tmp=ui;
|
||||||
|
[row,col]=find(isnan(ui(2:end-1,2:end-1))); row=row+1; col=col+1;
|
||||||
|
try
|
||||||
|
for ii=1:numel(col)
|
||||||
|
ro=row(ii);cl=col(ii);
|
||||||
|
% tmp(ro,cl)= (ui(ro-1,cl)+ui(ro+1,cl)+ui(ro,cl-1)+ui(ro,cl+1))/4;
|
||||||
|
tmp11=[ui(ro-1,cl) ui(ro+1,cl) ui(ro,cl-1) ui(ro,cl+1)];
|
||||||
|
chk_nan= ~isnan(tmp11);
|
||||||
|
tmp11(isnan(tmp11))=0;
|
||||||
|
tmp(ro,cl)= sum(tmp11.*chk_nan)/ sum(chk_nan(:));
|
||||||
|
|
||||||
|
end
|
||||||
|
catch
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[row,col]=find(isnan(ui(2:end-1,1))); row=row+1;
|
||||||
|
try
|
||||||
|
for ii=1:numel(col)
|
||||||
|
ro=row(ii);cl=col(ii);
|
||||||
|
if ~isnan(ui(ro,2))
|
||||||
|
tmp(ro,1)= ui(ro,2);
|
||||||
|
else tmp(ro,1)= tmp(ro,2);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
catch
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
[row,col]=find(isnan(ui(2:end-1,end))); row=row+1;
|
||||||
|
try
|
||||||
|
for ii=1:numel(col)
|
||||||
|
ro=row(ii);cl=col(ii);
|
||||||
|
if ~isnan(ui(ro,end-1))
|
||||||
|
tmp(ro,end)= ui(ro,end-1);
|
||||||
|
else
|
||||||
|
tmp(ro,end)= tmp(ro,end-1);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
catch
|
||||||
|
end
|
||||||
|
|
||||||
|
[row,col]=find(isnan(ui(end,2:end-1))); col=col+1;
|
||||||
|
try
|
||||||
|
for ii=1:numel(row)
|
||||||
|
cl=col(ii);
|
||||||
|
if ~isnan(ui(end-1,cl))
|
||||||
|
tmp(end,cl)= ui(end-1,cl);
|
||||||
|
else
|
||||||
|
tmp(end,cl)= tmp(end-1,cl);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
catch
|
||||||
|
end
|
||||||
|
|
||||||
|
[row,col]=find(isnan(ui(1,2:end-1))); col=col+1;
|
||||||
|
try
|
||||||
|
for ii=1:numel(row)
|
||||||
|
ro=row(ii);cl=col(ii);
|
||||||
|
if ~isnan(ui(2,cl))
|
||||||
|
tmp(1,cl)= ui(2,cl);
|
||||||
|
else
|
||||||
|
tmp(1,cl)= tmp(2,cl);
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
catch
|
||||||
|
end
|
||||||
|
|
||||||
|
if isnan(ui(1,1)), tmp(1,1)=tmp(2,2);end
|
||||||
|
if isnan(ui(end,end)), tmp(end,end)=tmp(end-1,end-1);end
|
||||||
|
if isnan(ui(1,end)), tmp(1,end)=tmp(2,end-1);end
|
||||||
|
if isnan(ui(end,1)), tmp(end,1)=tmp(end-1,2);end
|
||||||
|
|
||||||
|
u_inp1=tmp;
|
||||||
25
src/dic/DIC_check_vector.m
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
function[ iu_f, iv_f, i_cond ] = DIC_check_vector( iu, iv, vec_std, i_filter )
|
||||||
|
%========================================================================
|
||||||
|
%%========================================================================
|
||||||
|
|
||||||
|
mx = size(iu,1);
|
||||||
|
my = size(iu,2);
|
||||||
|
|
||||||
|
|
||||||
|
if i_filter == 2
|
||||||
|
|
||||||
|
[ iu_f, i_cond ] = DIC_vector_filter_median2( iu, vec_std );
|
||||||
|
[ iv_f, i_cond ] = DIC_vector_filter_median2( iv, vec_std );
|
||||||
|
|
||||||
|
|
||||||
|
iu_f = iu_f - iv_f*0;
|
||||||
|
iv_f = iv_f - iu_f*0;
|
||||||
|
|
||||||
|
else
|
||||||
|
iu_f=iu;
|
||||||
|
iv_f=iv;
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
90
src/dic/DIC_cor5.m
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
function [xi, yi, iu, iv] = DIC_cor5( im1, im2, ...
|
||||||
|
nx_pixel, ny_pixel, ...
|
||||||
|
overlap_x, overlap_y, ...
|
||||||
|
iu_max, iv_max, ...
|
||||||
|
i_mode )
|
||||||
|
%========================================================================
|
||||||
|
%======================================================================
|
||||||
|
|
||||||
|
|
||||||
|
% set area of search
|
||||||
|
p_search = 1/3; % percentage of subwindow
|
||||||
|
|
||||||
|
nx = size(im1,1);
|
||||||
|
ny = size(im1,2);
|
||||||
|
|
||||||
|
pixel_twx = ceil(p_search*nx_pixel);
|
||||||
|
pixel_twy = ceil(p_search*ny_pixel);
|
||||||
|
|
||||||
|
% (dx_center and dy_center)
|
||||||
|
[ xi, yi, nx_start, ny_start, nx_overlap, ny_overlap, dx_center, dy_center ] ...
|
||||||
|
= diccwindowsize32( 'mqd', ...
|
||||||
|
nx, ny, nx_pixel, ny_pixel, overlap_x, overlap_y );
|
||||||
|
|
||||||
|
% total number of vectors
|
||||||
|
mx = max(size(xi));
|
||||||
|
my = max(size(yi));
|
||||||
|
|
||||||
|
if rem(ny_pixel,2)==0, tem=ny_pixel;
|
||||||
|
else tem=ceil((ny_pixel+ny_pixel-1)/2); end
|
||||||
|
|
||||||
|
for iy = 1: my
|
||||||
|
|
||||||
|
c_proc = strcat( 'process accomplished : ', ...
|
||||||
|
num2str( 100*(iy-1)/(my-1),' %03.0f' ), '/100' );
|
||||||
|
disp( c_proc )
|
||||||
|
|
||||||
|
for ix = 1: mx
|
||||||
|
|
||||||
|
ix1 = xi(ix) - dx_center;
|
||||||
|
ix2 = ix1 + nx_pixel - 1;
|
||||||
|
iy1 = yi(iy) - dy_center;
|
||||||
|
iy2 = iy1 + ny_pixel - 1;
|
||||||
|
|
||||||
|
wn=nx_pixel/4;
|
||||||
|
ix11 = xi(ix) - dx_center -wn; if(ix11<1), ix11=1; end
|
||||||
|
ix22 = ix1 + nx_pixel - 1+ wn; if(ix22>size(im2,1)), ix22=size(im2,1); end
|
||||||
|
|
||||||
|
iy11 = yi(iy) - dy_center -wn; if(iy11<1), iy11=1; end
|
||||||
|
iy22 = iy1 + ny_pixel - 1 + wn; if(iy22>size(im2,2)), iy22=size(im2,2);end
|
||||||
|
|
||||||
|
f1 = im1( ix1:ix2, iy1:iy2 );
|
||||||
|
f2 = im2( ix11:ix22, iy11:iy22 );
|
||||||
|
|
||||||
|
C3=dic_xcor_m_mex(f1, f2);
|
||||||
|
[ ip_x3, ip_y3, MMR] = findpeak32_mex( C3, 1);
|
||||||
|
|
||||||
|
SNR = 3.00;
|
||||||
|
PPR = 1.10;
|
||||||
|
|
||||||
|
tx = round(size(C3,1)/2);
|
||||||
|
ix_peak = -( ip_y3-tx);
|
||||||
|
iy_peak = ( ip_x3-tx);
|
||||||
|
|
||||||
|
%
|
||||||
|
% --- eliminate odd displacement
|
||||||
|
%
|
||||||
|
|
||||||
|
if (iu_max == 0) & (iv_max == 0)
|
||||||
|
u_max_dipl = p_search*nx_pixel;
|
||||||
|
v_max_dipl = p_search*ny_pixel;
|
||||||
|
else
|
||||||
|
u_max_dipl = iu_max;
|
||||||
|
v_max_dipl = iv_max;
|
||||||
|
end
|
||||||
|
|
||||||
|
if ( abs(ix_peak) > u_max_dipl ) | ( abs(iy_peak) > v_max_dipl )
|
||||||
|
ix_peak = NaN;
|
||||||
|
iy_peak = NaN;
|
||||||
|
end
|
||||||
|
|
||||||
|
is_x(ix,iy) = ix_peak;
|
||||||
|
is_y(ix,iy) = iy_peak;
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
iu = -is_x;
|
||||||
|
iv = is_y;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
28
src/dic/DIC_filter2.m
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
function [iu_ft,iv_ft,iu_ip,iv_ip]=DIC_filter2( iu,iv, ...
|
||||||
|
i_filter, vec_std,...
|
||||||
|
i_interp, i_plot)
|
||||||
|
%========================================================================
|
||||||
|
%%========================================================================
|
||||||
|
%
|
||||||
|
% Local fitering to smooth
|
||||||
|
%
|
||||||
|
|
||||||
|
if i_filter ~= 0
|
||||||
|
|
||||||
|
[ iu_ft, iv_ft, i_cond ] = DIC_check_vector( iu, iv, vec_std, i_filter );
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if i_interp ~= 0
|
||||||
|
|
||||||
|
[ iu_ip ] = DIC_interp_vector( iu_ft, i_interp );
|
||||||
|
[ iv_ip ] = DIC_interp_vector( iv_ft, i_interp );
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
iu_ip = iu_ft;
|
||||||
|
iv_ip = iv_ft;
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
11
src/dic/DIC_interp_vector.m
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
function[ uo ] = DIC_interp_vector( ui, ii )
|
||||||
|
%========================================================================
|
||||||
|
|
||||||
|
uo = ui;
|
||||||
|
|
||||||
|
% interpolation
|
||||||
|
|
||||||
|
[ uo ] = DIC_spline_Interp_vector2( ui );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
96
src/dic/DIC_mqd5s.m
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
function [xi, yi, iu, iv, D] = DIC_mqd5s( im1, im2, ...
|
||||||
|
windo_x, windo_y, ...
|
||||||
|
X_overlap, Y_overlap, ...
|
||||||
|
u_max, v_max, ...
|
||||||
|
i_mode )
|
||||||
|
%========================================================================
|
||||||
|
%%
|
||||||
|
|
||||||
|
|
||||||
|
% set filter to eliminate stray vectors: 1-std, 2-median
|
||||||
|
i_filter = 2;
|
||||||
|
|
||||||
|
% Set threshold value (times of standard deviation)
|
||||||
|
% Vectors will be eliminated if exceeded
|
||||||
|
vec_std = 1.5;
|
||||||
|
|
||||||
|
% set interpolation of missing vector : 1-linear, 2-spline, 3-kriging
|
||||||
|
i_interp = 2;
|
||||||
|
|
||||||
|
% SNR: signal to noise ratio to find peak
|
||||||
|
r_SNR = 3.0;
|
||||||
|
|
||||||
|
% r_peak: ratio of maximum and mean
|
||||||
|
r_MMR = 1.10;
|
||||||
|
|
||||||
|
% r_peak: ratio of 1st peak and 2nd peak
|
||||||
|
r_PPR = 1.1;
|
||||||
|
|
||||||
|
% set area of search
|
||||||
|
p_search = 1/2; % percentage of subwindow
|
||||||
|
|
||||||
|
% min and max values for MQD
|
||||||
|
d_min = 10^(-5);
|
||||||
|
d_max = Inf;
|
||||||
|
|
||||||
|
%========================================================================
|
||||||
|
|
||||||
|
|
||||||
|
% --- initialization
|
||||||
|
%
|
||||||
|
|
||||||
|
im1 = double(im1);
|
||||||
|
im2 = double(im2);
|
||||||
|
|
||||||
|
nx = size(im1,1);
|
||||||
|
ny = size(im1,2);
|
||||||
|
|
||||||
|
% Get the seacrh area
|
||||||
|
if ( u_max <= 0 ) | ( v_max <= 0 )
|
||||||
|
x_maxDis = ceil( p_search*windo_x );
|
||||||
|
y_maxDis = ceil( p_search*windo_y );
|
||||||
|
else
|
||||||
|
|
||||||
|
x_maxDis = floor( u_max );
|
||||||
|
y_maxDis = floor( v_max );
|
||||||
|
if x_maxDis >= windo_x
|
||||||
|
x_maxDis = windo_x;
|
||||||
|
end
|
||||||
|
if y_maxDis >= windo_y
|
||||||
|
y_maxDis = windo_y;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
X_search = 2*x_maxDis + 1;
|
||||||
|
Y_search = 2*y_maxDis + 1;
|
||||||
|
|
||||||
|
% to obtain the center locations of all the subwindows
|
||||||
|
% (dx_center and dy_center)
|
||||||
|
[ xi, yi, nx_start, ny_start, nx_overlap, ny_overlap, dx_center, dy_center ] ...
|
||||||
|
= diccwindowsize2( 'mqd', nx, ny, windo_x, windo_y, X_overlap, Y_overlap );
|
||||||
|
|
||||||
|
dx_center
|
||||||
|
|
||||||
|
dy_center
|
||||||
|
|
||||||
|
|
||||||
|
bx=xi-dx_center+windo_x/2;
|
||||||
|
by=yi-dy_center+windo_y/2;
|
||||||
|
|
||||||
|
|
||||||
|
% number of vectors in x and y
|
||||||
|
mx = max(size(xi));
|
||||||
|
my = max(size(yi));
|
||||||
|
|
||||||
|
|
||||||
|
[xi,yi,iu,iv]=DIC_cor5( im1, im2, ...
|
||||||
|
windo_x, windo_y, ...
|
||||||
|
X_overlap, Y_overlap, ...
|
||||||
|
u_max, v_max, ...
|
||||||
|
i_mode )
|
||||||
|
D=[];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
9
src/dic/DIC_smooth.m
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
function [iu_s,iv_s] = DIC_smooth( iu, iv, i_plot)
|
||||||
|
%========================================================================
|
||||||
|
%
|
||||||
|
%========================================================================
|
||||||
|
|
||||||
|
iu_s = DIC_smooth_data(iu);
|
||||||
|
iv_s = DIC_smooth_data(iv);
|
||||||
|
|
||||||
|
i_plot =i_plot *1;
|
||||||
8
src/dic/DIC_smooth_data.m
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
function [y] = DIC_smooth_data(f)
|
||||||
|
%========================================================================
|
||||||
|
%%========================================================================
|
||||||
|
|
||||||
|
H= [1 2 1; 2 4 2; 1 2 1];
|
||||||
|
H= H / sum(H(:));
|
||||||
|
|
||||||
|
y=imfilter(f,H,'replicate');
|
||||||
19
src/dic/DIC_spline_Interp_vector2.m
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
function[ tmp1] = DIC_spline_Interp_vector2( ui )
|
||||||
|
%========================================================================
|
||||||
|
%========================================================================
|
||||||
|
|
||||||
|
[ u_inp1 ] = DIC_Linear_Interp_vector3( ui );
|
||||||
|
tmp=u_inp1;
|
||||||
|
|
||||||
|
[row,col]=find(isnan(ui)); %row=row1+2; col=col1+2;
|
||||||
|
[X, Y]= meshgrid(1:size(tmp,2),1:size(tmp,1));
|
||||||
|
Vq = interp2(X,Y,tmp,row,col);
|
||||||
|
|
||||||
|
tmp1=tmp;
|
||||||
|
|
||||||
|
for ii=1:numel(row)
|
||||||
|
tmp1(row(ii),col(ii))=Vq(ii);
|
||||||
|
end
|
||||||
|
|
||||||
|
if any(isnan(tmp1)), tmp1=u_inp1; end
|
||||||
|
|
||||||
38
src/dic/DIC_vector_filter_median2.m
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
function[ uo, ii ] = DIC_vector_filter_median2( ui, vec_std )
|
||||||
|
%========================================================================
|
||||||
|
dia=4;
|
||||||
|
err_int = 0.25;
|
||||||
|
u_new=zeros(size(ui,1)+dia, size(ui,2)+dia)+nan;
|
||||||
|
u_new(3:end-2, 3:end-2)=ui;
|
||||||
|
uo= zeros(size(ui));
|
||||||
|
[row, col]=size(ui);
|
||||||
|
ii=0;
|
||||||
|
for ri=1:row
|
||||||
|
for ci=1:col
|
||||||
|
tmp1 = u_new(ri:ri+4, ci:ci+4);
|
||||||
|
|
||||||
|
|
||||||
|
tmp = find(~isnan(tmp1));
|
||||||
|
f = tmp1(tmp);
|
||||||
|
|
||||||
|
[f_mean f_std f_med] = dic_filterHist3(f);
|
||||||
|
|
||||||
|
if abs( ui(ri,ci) - f_med ) > (max(err_int, vec_std*f_std))
|
||||||
|
uo(ri,ci)=nan; ii=1;
|
||||||
|
else
|
||||||
|
uo(ri,ci)=ui(ri,ci);
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
14
src/dic/cordinate_filter.m
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
function yD = cordinate_filter(yD1, s)
|
||||||
|
%#codegen
|
||||||
|
|
||||||
|
if ~isempty(yD1)
|
||||||
|
|
||||||
|
yD= round(yD1);
|
||||||
|
|
||||||
|
else
|
||||||
|
yD=[];
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
11
src/dic/dic_filterHist3.m
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
function[ u_mean, u_std, u_med] = dic_filterHist3( u )
|
||||||
|
|
||||||
|
limt = 2.0;
|
||||||
|
|
||||||
|
f = u(~isnan(u));
|
||||||
|
tm= f.*(abs(f-mean(f))<(limt*std(f)));
|
||||||
|
tm=tm(find(tm));
|
||||||
|
|
||||||
|
u_mean=mean(tm);
|
||||||
|
u_std= std(tm);
|
||||||
|
u_med= median(tm);
|
||||||
217
src/dic/dic_xcor_m.m
Normal file
@@ -0,0 +1,217 @@
|
|||||||
|
function C = dic_xcor_m(varargin)
|
||||||
|
|
||||||
|
%#codegen
|
||||||
|
|
||||||
|
[T, A] = ParseInputs(varargin{:});
|
||||||
|
|
||||||
|
% Haralick and Shapiro, Volume II (p. 317),
|
||||||
|
% "Fast Normalized Cross-Correlation", by J. P. Lewis, Industrial Light & Magic.
|
||||||
|
%
|
||||||
|
|
||||||
|
xcorr_TA = xcorr2_fast(T,A);
|
||||||
|
|
||||||
|
[m, n] = size(T);
|
||||||
|
mn = m*n;
|
||||||
|
|
||||||
|
local_sum_A = local_sum(A,m,n);
|
||||||
|
local_sum_A2 = local_sum(A.*A,m,n);
|
||||||
|
|
||||||
|
% Note: diff_local_sums should be nonnegative, but may have negative
|
||||||
|
% values due to round off errors. Below, we use max to ensure the
|
||||||
|
% radicand is nonnegative.
|
||||||
|
diff_local_sums = ( local_sum_A2 - (local_sum_A.^2)/mn );
|
||||||
|
denom_A = sqrt( max(diff_local_sums,0) );
|
||||||
|
|
||||||
|
denom_T = sqrt(mn-1)*std(T(:));
|
||||||
|
denom = denom_T*denom_A;
|
||||||
|
numerator = (xcorr_TA - local_sum_A*sum(T(:))/mn );
|
||||||
|
|
||||||
|
% We know denom_T~=0 from input parsing;
|
||||||
|
% so denom is only zero where denom_A is zero, and in
|
||||||
|
% these locations, C is also zero.
|
||||||
|
C = zeros(size(numerator));
|
||||||
|
tol = sqrt( eps( max(abs(denom(:)))) );
|
||||||
|
i_nonzero = find(denom > tol);
|
||||||
|
C(i_nonzero) = numerator(i_nonzero) ./ denom(i_nonzero);
|
||||||
|
|
||||||
|
% Another numerics backstop. If any of the coefficients are outside the
|
||||||
|
% range [-1 1], the numerics are unstable to small variance in A or T. In
|
||||||
|
% these cases, set C to zero to reflect undefined 0/0 condition.
|
||||||
|
C( ( abs(C) - 1 ) > sqrt(eps(1)) ) = 0;
|
||||||
|
|
||||||
|
%-------------------------------
|
||||||
|
% Function local_sum
|
||||||
|
%
|
||||||
|
function local_sum_A = local_sum(A,m,n)
|
||||||
|
|
||||||
|
% We thank Eli Horn for providing this code, used with his permission,
|
||||||
|
% to speed up the calculation of local sums. The algorithm depends on
|
||||||
|
% precomputing running sums as described in "Fast Normalized
|
||||||
|
% Cross-Correlation", by J. P. Lewis, Industrial Light & Magic.
|
||||||
|
|
||||||
|
B = padarray(A,[m n]);
|
||||||
|
s = cumsum(B,1);
|
||||||
|
c = s(1+m:end-1,:)-s(1:end-m-1,:);
|
||||||
|
s = cumsum(c,2);
|
||||||
|
local_sum_A = s(:,1+n:end-1)-s(:,1:end-n-1);
|
||||||
|
|
||||||
|
%-------------------------------
|
||||||
|
% Function xcorr2_fast
|
||||||
|
%
|
||||||
|
function cross_corr = xcorr2_fast(T,A)
|
||||||
|
|
||||||
|
T_size = size(T);
|
||||||
|
A_size = size(A);
|
||||||
|
outsize = A_size + T_size - 1;
|
||||||
|
|
||||||
|
% figure out when to use spatial domain vs. freq domain
|
||||||
|
conv_time = time_conv2(T_size,A_size); % 1 conv2
|
||||||
|
fft_time = 1*time_fft2(outsize); % 2 fft2 + 1 ifft2
|
||||||
|
|
||||||
|
cross_corr = conv2(rot90(T,2),A);
|
||||||
|
|
||||||
|
|
||||||
|
%-------------------------------
|
||||||
|
% Function freqxcorr
|
||||||
|
%
|
||||||
|
function xcorr_ab = freqxcorr(a,b,outsize)
|
||||||
|
|
||||||
|
% calculate correlation in frequency domain
|
||||||
|
Fa = fft2(rot90(a,2),outsize(1),outsize(2));
|
||||||
|
Fb = fft2(b,outsize(1),outsize(2));
|
||||||
|
% xcorr_ab = ifft2(Fa .* Fb,'symmetric');
|
||||||
|
xcorr_ab = real(ifft2(Fa .* Fb));
|
||||||
|
|
||||||
|
%-------------------------------
|
||||||
|
% Function time_conv2
|
||||||
|
%
|
||||||
|
function time = time_conv2(obssize,refsize)
|
||||||
|
|
||||||
|
% time a spatial domain convolution for 10-by-10 x 20-by-20 matrices
|
||||||
|
|
||||||
|
% a = ones(10);
|
||||||
|
% b = ones(20);
|
||||||
|
% mintime = 0.1;
|
||||||
|
|
||||||
|
% t1 = cputime;
|
||||||
|
% t2 = t1;
|
||||||
|
% k = 0;
|
||||||
|
% while (t2-t1)<mintime
|
||||||
|
% c = conv2(a,b);
|
||||||
|
% k = k + 1;
|
||||||
|
% t2 = cputime;
|
||||||
|
% end
|
||||||
|
% t_total = (t2-t1)/k;
|
||||||
|
|
||||||
|
% % convolution time = K*prod(size(a))*prod(size(b))
|
||||||
|
% % t_total = K*10*10*20*20 = 40000*K
|
||||||
|
% K = t_total/40000;
|
||||||
|
|
||||||
|
% K was empirically calculated by the commented-out code above.
|
||||||
|
K = 2.7e-8;
|
||||||
|
|
||||||
|
% convolution time = K*prod(obssize)*prod(refsize)
|
||||||
|
time = K*prod(obssize)*prod(refsize);
|
||||||
|
|
||||||
|
|
||||||
|
%-------------------------------
|
||||||
|
% Function time_fft2
|
||||||
|
%
|
||||||
|
function time = time_fft2(outsize)
|
||||||
|
|
||||||
|
% time a frequency domain convolution by timing two one-dimensional ffts
|
||||||
|
|
||||||
|
R = outsize(1);
|
||||||
|
S = outsize(2);
|
||||||
|
|
||||||
|
% Tr = time_fft(R);
|
||||||
|
% K_fft = Tr/(R*log(R));
|
||||||
|
|
||||||
|
% K_fft was empirically calculated by the 2 commented-out lines above.
|
||||||
|
K_fft = 3.3e-7;
|
||||||
|
Tr = K_fft*R*log(R);
|
||||||
|
|
||||||
|
if S==R
|
||||||
|
Ts = Tr;
|
||||||
|
else
|
||||||
|
% Ts = time_fft(S); % uncomment to estimate explicitly
|
||||||
|
Ts = K_fft*S*log(S);
|
||||||
|
end
|
||||||
|
|
||||||
|
time = S*Tr + R*Ts;
|
||||||
|
|
||||||
|
% %-------------------------------
|
||||||
|
% % Function time_fft
|
||||||
|
% %
|
||||||
|
% function T = time_fft(M)
|
||||||
|
|
||||||
|
% % time a complex fft that is M elements long
|
||||||
|
|
||||||
|
% vec = complex(ones(M,1),ones(M,1));
|
||||||
|
% mintime = 0.1;
|
||||||
|
|
||||||
|
% t1 = cputime;
|
||||||
|
% t2 = t1;
|
||||||
|
% k = 0;
|
||||||
|
% while (t2-t1) < mintime
|
||||||
|
% dummy = fft(vec);
|
||||||
|
% k = k + 1;
|
||||||
|
% t2 = cputime;
|
||||||
|
% end
|
||||||
|
% T = (t2-t1)/k;
|
||||||
|
|
||||||
|
|
||||||
|
%-----------------------------------------------------------------------------
|
||||||
|
function [T, A] = ParseInputs(varargin)
|
||||||
|
|
||||||
|
narginchk(2,2)
|
||||||
|
|
||||||
|
T = varargin{1};
|
||||||
|
A = varargin{2};
|
||||||
|
|
||||||
|
validateattributes(T,{'logical','numeric'},{'real','nonsparse','2d','finite'},mfilename,'T',1)
|
||||||
|
validateattributes(A,{'logical','numeric'},{'real','nonsparse','2d','finite'},mfilename,'A',2)
|
||||||
|
|
||||||
|
checkSizesTandA(T,A)
|
||||||
|
|
||||||
|
% See geck 342320. If either A or T has a minimum value which is negative, we
|
||||||
|
% need to shift the array so all values are positive to ensure numerically
|
||||||
|
% robust results for the normalized cross-correlation.
|
||||||
|
A = shiftData(A);
|
||||||
|
T = shiftData(T);
|
||||||
|
|
||||||
|
checkIfFlat(T);
|
||||||
|
|
||||||
|
%-----------------------------------------------------------------------------
|
||||||
|
function B = shiftData(A)
|
||||||
|
|
||||||
|
B = double(A);
|
||||||
|
|
||||||
|
is_unsigned = isa(A,'uint8') || isa(A,'uint16') || isa(A,'uint32');
|
||||||
|
if ~is_unsigned
|
||||||
|
|
||||||
|
min_B = min(B(:));
|
||||||
|
|
||||||
|
if min_B < 0
|
||||||
|
B = B - min_B;
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
%-----------------------------------------------------------------------------
|
||||||
|
function checkSizesTandA(T,A)
|
||||||
|
|
||||||
|
if numel(T) < 2
|
||||||
|
% error(message('images:xcorr2_norm:invalidTemplate'))
|
||||||
|
end
|
||||||
|
|
||||||
|
if size(A,1)<size(T,1) || size(A,2)<size(T,2)
|
||||||
|
% error(message('images:xcorr2_norm:invalidSizeForA'))
|
||||||
|
end
|
||||||
|
|
||||||
|
%-----------------------------------------------------------------------------
|
||||||
|
function checkIfFlat(T)
|
||||||
|
|
||||||
|
if std(T(:)) == 0
|
||||||
|
% error(message('images:xcorr2_norm:sameElementsInTemplate'))
|
||||||
|
end
|
||||||
46
src/dic/diccwindowsize32.m
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
function [ xi, yi, nx_start, ny_start, nx_overlap, ny_overlap, dxcenter, dycenter ] ...
|
||||||
|
= diccwindowsize32( type, ...
|
||||||
|
nx, ny, nx_pixel, ny_pixel, ...
|
||||||
|
overlap_x, overlap_y )
|
||||||
|
|
||||||
|
%========================================================================
|
||||||
|
% BJM
|
||||||
|
%Created 4-02-2013
|
||||||
|
%Modified: 6-02-2013, 10-04-2014 1-11-2017
|
||||||
|
%========================================================================
|
||||||
|
|
||||||
|
bordr = 1/4;
|
||||||
|
|
||||||
|
if type == 'mqd'
|
||||||
|
nx_start = nx_pixel*bordr;
|
||||||
|
ny_start = ny_pixel*bordr;
|
||||||
|
else
|
||||||
|
nx_start = 1;
|
||||||
|
ny_start = 1;
|
||||||
|
end
|
||||||
|
|
||||||
|
if mod(nx_pixel, 2) == 0
|
||||||
|
dxc = nx_pixel/2 + 0.5;
|
||||||
|
else
|
||||||
|
dxc = nx_pixel/2;
|
||||||
|
end
|
||||||
|
|
||||||
|
if mod(ny_pixel, 2) == 0
|
||||||
|
dyc = ny_pixel/2 + 0.5;
|
||||||
|
else
|
||||||
|
dyc = ny_pixel/2;
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
% number of vectors
|
||||||
|
|
||||||
|
dycenter=ny_pixel/2+0.5;
|
||||||
|
dxcenter=nx_pixel/2+0.5;
|
||||||
|
|
||||||
|
xi=(floor(nx_pixel/2+nx_pixel*bordr)+0.5: ceil((1-overlap_x)*nx_pixel):(nx-ceil(nx_pixel/2+nx_pixel*bordr)+1));
|
||||||
|
yi=(floor(ny_pixel/2+ny_pixel*bordr)+0.5: ceil((1-overlap_y)*ny_pixel):(ny-ceil(ny_pixel/2+ny_pixel*bordr)+1));
|
||||||
|
|
||||||
|
|
||||||
|
nx_overlap = floor( nx_pixel*overlap_x );
|
||||||
|
ny_overlap = floor( ny_pixel*overlap_y );
|
||||||
|
|
||||||
6
src/dic/findpeak32.m
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
function [xpeak, ypeak, max_f] = findpeak32(f,subpixel)
|
||||||
|
[max_f, imax] = max(abs(f(:)));
|
||||||
|
[ypeak, xpeak] = ind2sub(size(f),imax(1));
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
275
src/dic/freezeColors.m
Normal file
@@ -0,0 +1,275 @@
|
|||||||
|
function freezeColors(varargin)
|
||||||
|
% freezeColors Lock colors of plot, enabling multiple colormaps per figure. (v2.3)
|
||||||
|
%
|
||||||
|
% Problem: There is only one colormap per figure. This function provides
|
||||||
|
% an easy solution when plots using different colomaps are desired
|
||||||
|
% in the same figure.
|
||||||
|
%
|
||||||
|
% freezeColors freezes the colors of graphics objects in the current axis so
|
||||||
|
% that subsequent changes to the colormap (or caxis) will not change the
|
||||||
|
% colors of these objects. freezeColors works on any graphics object
|
||||||
|
% with CData in indexed-color mode: surfaces, images, scattergroups,
|
||||||
|
% bargroups, patches, etc. It works by converting CData to true-color rgb
|
||||||
|
% based on the colormap active at the time freezeColors is called.
|
||||||
|
%
|
||||||
|
% The original indexed color data is saved, and can be restored using
|
||||||
|
% unfreezeColors, making the plot once again subject to the colormap and
|
||||||
|
% caxis.
|
||||||
|
%
|
||||||
|
%
|
||||||
|
% Usage:
|
||||||
|
% freezeColors applies to all objects in current axis (gca),
|
||||||
|
% freezeColors(axh) same, but works on axis axh.
|
||||||
|
%
|
||||||
|
% Example:
|
||||||
|
% subplot(2,1,1); imagesc(X); colormap hot; freezeColors
|
||||||
|
% subplot(2,1,2); imagesc(Y); colormap hsv; freezeColors etc...
|
||||||
|
%
|
||||||
|
% Note: colorbars must also be frozen. Due to Matlab 'improvements' this can
|
||||||
|
% no longer be done with freezeColors. Instead, please
|
||||||
|
% use the function CBFREEZE by Carlos Adrian Vargas Aguilera
|
||||||
|
% that can be downloaded from the MATLAB File Exchange
|
||||||
|
% (http://www.mathworks.com/matlabcentral/fileexchange/24371)
|
||||||
|
%
|
||||||
|
% h=colorbar; cbfreeze(h), or simply cbfreeze(colorbar)
|
||||||
|
%
|
||||||
|
% For additional examples, see test/test_main.m
|
||||||
|
%
|
||||||
|
% Side effect on render mode: freezeColors does not work with the painters
|
||||||
|
% renderer, because Matlab doesn't support rgb color data in
|
||||||
|
% painters mode. If the current renderer is painters, freezeColors
|
||||||
|
% changes it to zbuffer. This may have unexpected effects on other aspects
|
||||||
|
% of your plots.
|
||||||
|
%
|
||||||
|
% See also unfreezeColors, freezeColors_pub.html, cbfreeze.
|
||||||
|
%
|
||||||
|
%
|
||||||
|
% John Iversen (iversen@nsi.edu) 3/23/05
|
||||||
|
%
|
||||||
|
|
||||||
|
% Changes:
|
||||||
|
% JRI (iversen@nsi.edu) 4/19/06 Correctly handles scaled integer cdata
|
||||||
|
% JRI 9/1/06 should now handle all objects with cdata: images, surfaces,
|
||||||
|
% scatterplots. (v 2.1)
|
||||||
|
% JRI 11/11/06 Preserves NaN colors. Hidden option (v 2.2, not uploaded)
|
||||||
|
% JRI 3/17/07 Preserve caxis after freezing--maintains colorbar scale (v 2.3)
|
||||||
|
% JRI 4/12/07 Check for painters mode as Matlab doesn't support rgb in it.
|
||||||
|
% JRI 4/9/08 Fix preserving caxis for objects within hggroups (e.g. contourf)
|
||||||
|
% JRI 4/7/10 Change documentation for colorbars
|
||||||
|
|
||||||
|
% Hidden option for NaN colors:
|
||||||
|
% Missing data are often represented by NaN in the indexed color
|
||||||
|
% data, which renders transparently. This transparency will be preserved
|
||||||
|
% when freezing colors. If instead you wish such gaps to be filled with
|
||||||
|
% a real color, add 'nancolor',[r g b] to the end of the arguments. E.g.
|
||||||
|
% freezeColors('nancolor',[r g b]) or freezeColors(axh,'nancolor',[r g b]),
|
||||||
|
% where [r g b] is a color vector. This works on images & pcolor, but not on
|
||||||
|
% surfaces.
|
||||||
|
% Thanks to Fabiano Busdraghi and Jody Klymak for the suggestions. Bugfixes
|
||||||
|
% attributed in the code.
|
||||||
|
|
||||||
|
% Free for all uses, but please retain the following:
|
||||||
|
% Original Author:
|
||||||
|
% John Iversen, 2005-10
|
||||||
|
% john_iversen@post.harvard.edu
|
||||||
|
|
||||||
|
appdatacode = 'JRI__freezeColorsData';
|
||||||
|
|
||||||
|
[h, nancolor] = checkArgs(varargin);
|
||||||
|
|
||||||
|
%gather all children with scaled or indexed CData
|
||||||
|
cdatah = getCDataHandles(h);
|
||||||
|
|
||||||
|
%current colormap
|
||||||
|
cmap = colormap;
|
||||||
|
nColors = size(cmap,1);
|
||||||
|
cax = caxis;
|
||||||
|
|
||||||
|
% convert object color indexes into colormap to true-color data using
|
||||||
|
% current colormap
|
||||||
|
for hh = cdatah',
|
||||||
|
g = get(hh);
|
||||||
|
|
||||||
|
%preserve parent axis clim
|
||||||
|
parentAx = getParentAxes(hh);
|
||||||
|
originalClim = get(parentAx, 'clim');
|
||||||
|
|
||||||
|
% Note: Special handling of patches: For some reason, setting
|
||||||
|
% cdata on patches created by bar() yields an error,
|
||||||
|
% so instead we'll set facevertexcdata instead for patches.
|
||||||
|
if ~strcmp(g.Type,'patch'),
|
||||||
|
cdata = g.CData;
|
||||||
|
else
|
||||||
|
cdata = g.FaceVertexCData;
|
||||||
|
end
|
||||||
|
|
||||||
|
%get cdata mapping (most objects (except scattergroup) have it)
|
||||||
|
if isfield(g,'CDataMapping'),
|
||||||
|
scalemode = g.CDataMapping;
|
||||||
|
else
|
||||||
|
scalemode = 'scaled';
|
||||||
|
end
|
||||||
|
|
||||||
|
%save original indexed data for use with unfreezeColors
|
||||||
|
siz = size(cdata);
|
||||||
|
setappdata(hh, appdatacode, {cdata scalemode});
|
||||||
|
|
||||||
|
%convert cdata to indexes into colormap
|
||||||
|
if strcmp(scalemode,'scaled'),
|
||||||
|
%4/19/06 JRI, Accommodate scaled display of integer cdata:
|
||||||
|
% in MATLAB, uint * double = uint, so must coerce cdata to double
|
||||||
|
% Thanks to O Yamashita for pointing this need out
|
||||||
|
idx = ceil( (double(cdata) - cax(1)) / (cax(2)-cax(1)) * nColors);
|
||||||
|
else %direct mapping
|
||||||
|
idx = cdata;
|
||||||
|
%10/8/09 in case direct data is non-int (e.g. image;freezeColors)
|
||||||
|
% (Floor mimics how matlab converts data into colormap index.)
|
||||||
|
% Thanks to D Armyr for the catch
|
||||||
|
idx = floor(idx);
|
||||||
|
end
|
||||||
|
|
||||||
|
%clamp to [1, nColors]
|
||||||
|
idx(idx<1) = 1;
|
||||||
|
idx(idx>nColors) = nColors;
|
||||||
|
|
||||||
|
%handle nans in idx
|
||||||
|
nanmask = isnan(idx);
|
||||||
|
idx(nanmask)=1; %temporarily replace w/ a valid colormap index
|
||||||
|
|
||||||
|
%make true-color data--using current colormap
|
||||||
|
realcolor = zeros(siz);
|
||||||
|
for i = 1:3,
|
||||||
|
c = cmap(idx,i);
|
||||||
|
c = reshape(c,siz);
|
||||||
|
c(nanmask) = nancolor(i); %restore Nan (or nancolor if specified)
|
||||||
|
realcolor(:,:,i) = c;
|
||||||
|
end
|
||||||
|
|
||||||
|
%apply new true-color color data
|
||||||
|
|
||||||
|
%true-color is not supported in painters renderer, so switch out of that
|
||||||
|
if strcmp(get(gcf,'renderer'), 'painters'),
|
||||||
|
set(gcf,'renderer','opengl');
|
||||||
|
end
|
||||||
|
|
||||||
|
%replace original CData with true-color data
|
||||||
|
if ~strcmp(g.Type,'patch'),
|
||||||
|
set(hh,'CData',realcolor);
|
||||||
|
else
|
||||||
|
set(hh,'faceVertexCData',permute(realcolor,[1 3 2]))
|
||||||
|
end
|
||||||
|
|
||||||
|
%restore clim (so colorbar will show correct limits)
|
||||||
|
if ~isempty(parentAx),
|
||||||
|
set(parentAx,'clim',originalClim)
|
||||||
|
end
|
||||||
|
|
||||||
|
end %loop on indexed-color objects
|
||||||
|
|
||||||
|
|
||||||
|
% ============================================================================ %
|
||||||
|
% Local functions
|
||||||
|
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
%% getCDataHandles -- get handles of all descendents with indexed CData
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
|
function hout = getCDataHandles(h)
|
||||||
|
% getCDataHandles Find all objects with indexed CData
|
||||||
|
|
||||||
|
%recursively descend object tree, finding objects with indexed CData
|
||||||
|
% An exception: don't include children of objects that themselves have CData:
|
||||||
|
% for example, scattergroups are non-standard hggroups, with CData. Changing
|
||||||
|
% such a group's CData automatically changes the CData of its children,
|
||||||
|
% (as well as the children's handles), so there's no need to act on them.
|
||||||
|
|
||||||
|
error(nargchk(1,1,nargin,'struct'))
|
||||||
|
|
||||||
|
hout = [];
|
||||||
|
if isempty(h),return;end
|
||||||
|
|
||||||
|
ch = get(h,'children');
|
||||||
|
for hh = ch'
|
||||||
|
g = get(hh);
|
||||||
|
if isfield(g,'CData'), %does object have CData?
|
||||||
|
%is it indexed/scaled?
|
||||||
|
if ~isempty(g.CData) && isnumeric(g.CData) && size(g.CData,3)==1,
|
||||||
|
hout = [hout; hh]; %#ok<AGROW> %yes, add to list
|
||||||
|
end
|
||||||
|
else %no CData, see if object has any interesting children
|
||||||
|
hout = [hout; getCDataHandles(hh)]; %#ok<AGROW>
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
%% getParentAxes -- return handle of axes object to which a given object belongs
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
function hAx = getParentAxes(h)
|
||||||
|
% getParentAxes Return enclosing axes of a given object (could be self)
|
||||||
|
|
||||||
|
error(nargchk(1,1,nargin,'struct'))
|
||||||
|
%object itself may be an axis
|
||||||
|
if strcmp(get(h,'type'),'axes'),
|
||||||
|
hAx = h;
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
parent = get(h,'parent');
|
||||||
|
if (strcmp(get(parent,'type'), 'axes')),
|
||||||
|
hAx = parent;
|
||||||
|
else
|
||||||
|
hAx = getParentAxes(parent);
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
%% checkArgs -- Validate input arguments
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
|
function [h, nancolor] = checkArgs(args)
|
||||||
|
% checkArgs Validate input arguments to freezeColors
|
||||||
|
|
||||||
|
nargs = length(args);
|
||||||
|
error(nargchk(0,3,nargs,'struct'))
|
||||||
|
|
||||||
|
%grab handle from first argument if we have an odd number of arguments
|
||||||
|
if mod(nargs,2),
|
||||||
|
h = args{1};
|
||||||
|
if ~ishandle(h),
|
||||||
|
error('JRI:freezeColors:checkArgs:invalidHandle',...
|
||||||
|
'The first argument must be a valid graphics handle (to an axis)')
|
||||||
|
end
|
||||||
|
% 4/2010 check if object to be frozen is a colorbar
|
||||||
|
if strcmp(get(h,'Tag'),'Colorbar'),
|
||||||
|
if ~exist('cbfreeze.m'),
|
||||||
|
warning('JRI:freezeColors:checkArgs:cannotFreezeColorbar',...
|
||||||
|
['You seem to be attempting to freeze a colorbar. This no longer'...
|
||||||
|
'works. Please read the help for freezeColors for the solution.'])
|
||||||
|
else
|
||||||
|
cbfreeze(h);
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
args{1} = [];
|
||||||
|
nargs = nargs-1;
|
||||||
|
else
|
||||||
|
h = gca;
|
||||||
|
end
|
||||||
|
|
||||||
|
%set nancolor if that option was specified
|
||||||
|
nancolor = [nan nan nan];
|
||||||
|
if nargs == 2,
|
||||||
|
if strcmpi(args{end-1},'nancolor'),
|
||||||
|
nancolor = args{end};
|
||||||
|
if ~all(size(nancolor)==[1 3]),
|
||||||
|
error('JRI:freezeColors:checkArgs:badColorArgument',...
|
||||||
|
'nancolor must be [r g b] vector');
|
||||||
|
end
|
||||||
|
nancolor(nancolor>1) = 1; nancolor(nancolor<0) = 0;
|
||||||
|
else
|
||||||
|
error('JRI:freezeColors:checkArgs:unrecognizedOption',...
|
||||||
|
'Unrecognized option (%s). Only ''nancolor'' is valid.',args{end-1})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
81
src/dic/gui_DIC_overlapCheck.m
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
function varargout = gui_DIC_overlapCheck(varargin)
|
||||||
|
% GUI_DIC_OVERLAPCHECK MATLAB code for gui_DIC_overlapCheck.fig
|
||||||
|
% GUI_DIC_OVERLAPCHECK, by itself, creates a new GUI_DIC_OVERLAPCHECK or raises the existing
|
||||||
|
% singleton*.
|
||||||
|
%
|
||||||
|
% H = GUI_DIC_OVERLAPCHECK returns the handle to a new GUI_DIC_OVERLAPCHECK or the handle to
|
||||||
|
% the existing singleton*.
|
||||||
|
%
|
||||||
|
% GUI_DIC_OVERLAPCHECK('CALLBACK',hObject,eventData,handles,...) calls the local
|
||||||
|
% function named CALLBACK in GUI_DIC_OVERLAPCHECK.M with the given input arguments.
|
||||||
|
%
|
||||||
|
% GUI_DIC_OVERLAPCHECK('Property','Value',...) creates a new GUI_DIC_OVERLAPCHECK or raises the
|
||||||
|
% existing singleton*. Starting from the left, property value pairs are
|
||||||
|
% applied to the GUI before gui_DIC_overlapCheck_OpeningFcn gets called. An
|
||||||
|
% unrecognized property name or invalid value makes property application
|
||||||
|
% stop. All inputs are passed to gui_DIC_overlapCheck_OpeningFcn via varargin.
|
||||||
|
%
|
||||||
|
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
|
||||||
|
% instance to run (singleton)".
|
||||||
|
%
|
||||||
|
% See also: GUIDE, GUIDATA, GUIHANDLES
|
||||||
|
|
||||||
|
% Edit the above text to modify the response to help gui_DIC_overlapCheck
|
||||||
|
|
||||||
|
% Last Modified by GUIDE v2.5 27-Dec-2017 13:10:48
|
||||||
|
|
||||||
|
% Begin initialization code - DO NOT EDIT
|
||||||
|
gui_Singleton = 1;
|
||||||
|
gui_State = struct('gui_Name', mfilename, ...
|
||||||
|
'gui_Singleton', gui_Singleton, ...
|
||||||
|
'gui_OpeningFcn', @gui_DIC_overlapCheck_OpeningFcn, ...
|
||||||
|
'gui_OutputFcn', @gui_DIC_overlapCheck_OutputFcn, ...
|
||||||
|
'gui_LayoutFcn', [] , ...
|
||||||
|
'gui_Callback', []);
|
||||||
|
if nargin && ischar(varargin{1})
|
||||||
|
gui_State.gui_Callback = str2func(varargin{1});
|
||||||
|
end
|
||||||
|
|
||||||
|
if nargout
|
||||||
|
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
|
||||||
|
else
|
||||||
|
gui_mainfcn(gui_State, varargin{:});
|
||||||
|
end
|
||||||
|
% End initialization code - DO NOT EDIT
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes just before gui_DIC_overlapCheck is made visible.
|
||||||
|
function gui_DIC_overlapCheck_OpeningFcn(hObject, eventdata, handles, varargin)
|
||||||
|
% This function has no output args, see OutputFcn.
|
||||||
|
% hObject handle to figure
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
% varargin command line arguments to gui_DIC_overlapCheck (see VARARGIN)
|
||||||
|
|
||||||
|
% Choose default command line output for gui_DIC_overlapCheck
|
||||||
|
handles.output = hObject;
|
||||||
|
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
% UIWAIT makes gui_DIC_overlapCheck wait for user response (see UIRESUME)
|
||||||
|
% uiwait(handles.figure1);
|
||||||
|
|
||||||
|
|
||||||
|
% --- Outputs from this function are returned to the command line.
|
||||||
|
function varargout = gui_DIC_overlapCheck_OutputFcn(hObject, eventdata, handles)
|
||||||
|
% varargout cell array for returning output args (see VARARGOUT);
|
||||||
|
% hObject handle to figure
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
% Get default command line output from handles structure
|
||||||
|
varargout{1} = handles.output;
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on button press in pushbutton1.
|
||||||
|
function pushbutton1_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to pushbutton1 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
delete(handles.figure1);
|
||||||
206
src/dic/gui_DIC_sizeCheck.m
Normal file
@@ -0,0 +1,206 @@
|
|||||||
|
function varargout = gui_DIC_sizeCheck(varargin)
|
||||||
|
% GUI_DIC_SIZECHECK MATLAB code for gui_DIC_sizeCheck.fig
|
||||||
|
% GUI_DIC_SIZECHECK by itself, creates a new GUI_DIC_SIZECHECK or raises the
|
||||||
|
% existing singleton*.
|
||||||
|
%
|
||||||
|
% H = GUI_DIC_SIZECHECK returns the handle to a new GUI_DIC_SIZECHECK or the handle to
|
||||||
|
% the existing singleton*.
|
||||||
|
%
|
||||||
|
% GUI_DIC_SIZECHECK('CALLBACK',hObject,eventData,handles,...) calls the local
|
||||||
|
% function named CALLBACK in GUI_DIC_SIZECHECK.M with the given input arguments.
|
||||||
|
%
|
||||||
|
% GUI_DIC_SIZECHECK('Property','Value',...) creates a new GUI_DIC_SIZECHECK or raises the
|
||||||
|
% existing singleton*. Starting from the left, property value pairs are
|
||||||
|
% applied to the GUI before gui_DIC_sizeCheck_OpeningFcn gets called. An
|
||||||
|
% unrecognized property name or invalid value makes property application
|
||||||
|
% stop. All inputs are passed to gui_DIC_sizeCheck_OpeningFcn via varargin.
|
||||||
|
%
|
||||||
|
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
|
||||||
|
% instance to run (singleton)".
|
||||||
|
%
|
||||||
|
% See also: GUIDE, GUIDATA, GUIHANDLES
|
||||||
|
|
||||||
|
% Edit the above text to modify the response to help gui_DIC_sizeCheck
|
||||||
|
|
||||||
|
% Last Modified by GUIDE v2.5 27-Dec-2017 11:33:02
|
||||||
|
|
||||||
|
% Begin initialization code - DO NOT EDIT
|
||||||
|
gui_Singleton = 1;
|
||||||
|
gui_State = struct('gui_Name', mfilename, ...
|
||||||
|
'gui_Singleton', gui_Singleton, ...
|
||||||
|
'gui_OpeningFcn', @gui_DIC_sizeCheck_OpeningFcn, ...
|
||||||
|
'gui_OutputFcn', @gui_DIC_sizeCheck_OutputFcn, ...
|
||||||
|
'gui_LayoutFcn', [] , ...
|
||||||
|
'gui_Callback', []);
|
||||||
|
if nargin && ischar(varargin{1})
|
||||||
|
gui_State.gui_Callback = str2func(varargin{1});
|
||||||
|
end
|
||||||
|
|
||||||
|
if nargout
|
||||||
|
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
|
||||||
|
else
|
||||||
|
gui_mainfcn(gui_State, varargin{:});
|
||||||
|
end
|
||||||
|
% End initialization code - DO NOT EDIT
|
||||||
|
|
||||||
|
% --- Executes just before gui_DIC_sizeCheck is made visible.
|
||||||
|
function gui_DIC_sizeCheck_OpeningFcn(hObject, eventdata, handles, varargin)
|
||||||
|
% This function has no output args, see OutputFcn.
|
||||||
|
% hObject handle to figure
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
% varargin command line arguments to gui_DIC_sizeCheck (see VARARGIN)
|
||||||
|
|
||||||
|
% Choose default command line output for gui_DIC_sizeCheck
|
||||||
|
handles.output = 'Yes';
|
||||||
|
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
% Insert custom Title and Text if specified by the user
|
||||||
|
% Hint: when choosing keywords, be sure they are not easily confused
|
||||||
|
% with existing figure properties. See the output of set(figure) for
|
||||||
|
% a list of figure properties.
|
||||||
|
if(nargin > 3)
|
||||||
|
for index = 1:2:(nargin-3),
|
||||||
|
if nargin-3==index, break, end
|
||||||
|
switch lower(varargin{index})
|
||||||
|
case 'title'
|
||||||
|
set(hObject, 'Name', varargin{index+1});
|
||||||
|
case 'string'
|
||||||
|
set(handles.text1, 'String', varargin{index+1});
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
% Determine the position of the dialog - centered on the callback figure
|
||||||
|
% if available, else, centered on the screen
|
||||||
|
FigPos=get(0,'DefaultFigurePosition');
|
||||||
|
OldUnits = get(hObject, 'Units');
|
||||||
|
set(hObject, 'Units', 'pixels');
|
||||||
|
OldPos = get(hObject,'Position');
|
||||||
|
FigWidth = OldPos(3);
|
||||||
|
FigHeight = OldPos(4);
|
||||||
|
if isempty(gcbf)
|
||||||
|
ScreenUnits=get(0,'Units');
|
||||||
|
set(0,'Units','pixels');
|
||||||
|
ScreenSize=get(0,'ScreenSize');
|
||||||
|
set(0,'Units',ScreenUnits);
|
||||||
|
|
||||||
|
FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
|
||||||
|
FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
|
||||||
|
else
|
||||||
|
GCBFOldUnits = get(gcbf,'Units');
|
||||||
|
set(gcbf,'Units','pixels');
|
||||||
|
GCBFPos = get(gcbf,'Position');
|
||||||
|
set(gcbf,'Units',GCBFOldUnits);
|
||||||
|
FigPos(1:2) = [(GCBFPos(1) + GCBFPos(3) / 2) - FigWidth / 2, ...
|
||||||
|
(GCBFPos(2) + GCBFPos(4) / 2) - FigHeight / 2];
|
||||||
|
end
|
||||||
|
FigPos(3:4)=[FigWidth FigHeight];
|
||||||
|
set(hObject, 'Position', FigPos);
|
||||||
|
set(hObject, 'Units', OldUnits);
|
||||||
|
|
||||||
|
% Show a question icon from dialogicons.mat - variables questIconData
|
||||||
|
% and questIconMap
|
||||||
|
load dialogicons.mat
|
||||||
|
|
||||||
|
IconData=questIconData;
|
||||||
|
questIconMap(256,:) = get(handles.figure1, 'Color');
|
||||||
|
IconCMap=questIconMap;
|
||||||
|
|
||||||
|
Img=image(IconData, 'Parent', handles.axes1);
|
||||||
|
set(handles.figure1, 'Colormap', IconCMap);
|
||||||
|
|
||||||
|
set(handles.axes1, ...
|
||||||
|
'Visible', 'off', ...
|
||||||
|
'YDir' , 'reverse' , ...
|
||||||
|
'XLim' , get(Img,'XData'), ...
|
||||||
|
'YLim' , get(Img,'YData') ...
|
||||||
|
);
|
||||||
|
|
||||||
|
% Make the GUI modal
|
||||||
|
set(handles.figure1,'WindowStyle','modal')
|
||||||
|
|
||||||
|
% UIWAIT makes gui_DIC_sizeCheck wait for user response (see UIRESUME)
|
||||||
|
uiwait(handles.figure1);
|
||||||
|
|
||||||
|
% --- Outputs from this function are returned to the command line.
|
||||||
|
function varargout = gui_DIC_sizeCheck_OutputFcn(hObject, eventdata, handles)
|
||||||
|
% varargout cell array for returning output args (see VARARGOUT);
|
||||||
|
% hObject handle to figure
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
% Get default command line output from handles structure
|
||||||
|
varargout{1} = handles.output;
|
||||||
|
|
||||||
|
% The figure can be deleted now
|
||||||
|
delete(handles.figure1);
|
||||||
|
|
||||||
|
% --- Executes on button press in pushbutton1.
|
||||||
|
function pushbutton1_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to pushbutton1 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
handles.output = get(hObject,'String');
|
||||||
|
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
% Use UIRESUME instead of delete because the OutputFcn needs
|
||||||
|
% to get the updated handles structure.
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
|
||||||
|
% --- Executes on button press in pushbutton2.
|
||||||
|
function pushbutton2_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to pushbutton2 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
handles.output = get(hObject,'String');
|
||||||
|
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
% Use UIRESUME instead of delete because the OutputFcn needs
|
||||||
|
% to get the updated handles structure.
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes when user attempts to close figure1.
|
||||||
|
function figure1_CloseRequestFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to figure1 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
if isequal(get(hObject, 'waitstatus'), 'waiting')
|
||||||
|
% The GUI is still in UIWAIT, us UIRESUME
|
||||||
|
uiresume(hObject);
|
||||||
|
else
|
||||||
|
% The GUI is no longer waiting, just close it
|
||||||
|
delete(hObject);
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on key press over figure1 with no controls selected.
|
||||||
|
function figure1_KeyPressFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to figure1 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
% Check for "enter" or "escape"
|
||||||
|
if isequal(get(hObject,'CurrentKey'),'escape')
|
||||||
|
% User said no by hitting escape
|
||||||
|
handles.output = 'No';
|
||||||
|
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
end
|
||||||
|
|
||||||
|
if isequal(get(hObject,'CurrentKey'),'return')
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
end
|
||||||
81
src/dic/gui_DIC_sizeCheck1.m
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
function varargout = gui_DIC_sizeCheck1(varargin)
|
||||||
|
% GUI_DIC_SIZECHECK1 MATLAB code for gui_DIC_sizeCheck1.fig
|
||||||
|
% GUI_DIC_SIZECHECK1, by itself, creates a new GUI_DIC_SIZECHECK1 or raises the existing
|
||||||
|
% singleton*.
|
||||||
|
%
|
||||||
|
% H = GUI_DIC_SIZECHECK1 returns the handle to a new GUI_DIC_SIZECHECK1 or the handle to
|
||||||
|
% the existing singleton*.
|
||||||
|
%
|
||||||
|
% GUI_DIC_SIZECHECK1('CALLBACK',hObject,eventData,handles,...) calls the local
|
||||||
|
% function named CALLBACK in GUI_DIC_SIZECHECK1.M with the given input arguments.
|
||||||
|
%
|
||||||
|
% GUI_DIC_SIZECHECK1('Property','Value',...) creates a new GUI_DIC_SIZECHECK1 or raises the
|
||||||
|
% existing singleton*. Starting from the left, property value pairs are
|
||||||
|
% applied to the GUI before gui_DIC_sizeCheck1_OpeningFcn gets called. An
|
||||||
|
% unrecognized property name or invalid value makes property application
|
||||||
|
% stop. All inputs are passed to gui_DIC_sizeCheck1_OpeningFcn via varargin.
|
||||||
|
%
|
||||||
|
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
|
||||||
|
% instance to run (singleton)".
|
||||||
|
%
|
||||||
|
% See also: GUIDE, GUIDATA, GUIHANDLES
|
||||||
|
|
||||||
|
% Edit the above text to modify the response to help gui_DIC_sizeCheck1
|
||||||
|
|
||||||
|
% Last Modified by GUIDE v2.5 27-Dec-2017 12:07:24
|
||||||
|
|
||||||
|
% Begin initialization code - DO NOT EDIT
|
||||||
|
gui_Singleton = 1;
|
||||||
|
gui_State = struct('gui_Name', mfilename, ...
|
||||||
|
'gui_Singleton', gui_Singleton, ...
|
||||||
|
'gui_OpeningFcn', @gui_DIC_sizeCheck1_OpeningFcn, ...
|
||||||
|
'gui_OutputFcn', @gui_DIC_sizeCheck1_OutputFcn, ...
|
||||||
|
'gui_LayoutFcn', [] , ...
|
||||||
|
'gui_Callback', []);
|
||||||
|
if nargin && ischar(varargin{1})
|
||||||
|
gui_State.gui_Callback = str2func(varargin{1});
|
||||||
|
end
|
||||||
|
|
||||||
|
if nargout
|
||||||
|
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
|
||||||
|
else
|
||||||
|
gui_mainfcn(gui_State, varargin{:});
|
||||||
|
end
|
||||||
|
% End initialization code - DO NOT EDIT
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes just before gui_DIC_sizeCheck1 is made visible.
|
||||||
|
function gui_DIC_sizeCheck1_OpeningFcn(hObject, eventdata, handles, varargin)
|
||||||
|
% This function has no output args, see OutputFcn.
|
||||||
|
% hObject handle to figure
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
% varargin command line arguments to gui_DIC_sizeCheck1 (see VARARGIN)
|
||||||
|
|
||||||
|
% Choose default command line output for gui_DIC_sizeCheck1
|
||||||
|
handles.output = hObject;
|
||||||
|
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
% UIWAIT makes gui_DIC_sizeCheck1 wait for user response (see UIRESUME)
|
||||||
|
% uiwait(handles.figure1);
|
||||||
|
|
||||||
|
|
||||||
|
% --- Outputs from this function are returned to the command line.
|
||||||
|
function varargout = gui_DIC_sizeCheck1_OutputFcn(hObject, eventdata, handles)
|
||||||
|
% varargout cell array for returning output args (see VARARGOUT);
|
||||||
|
% hObject handle to figure
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
% Get default command line output from handles structure
|
||||||
|
varargout{1} = handles.output;
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on button press in pushbutton1.
|
||||||
|
function pushbutton1_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to pushbutton1 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
delete(handles.figure1);
|
||||||
271
src/dic/gui_Image_Crop_1.m
Normal file
@@ -0,0 +1,271 @@
|
|||||||
|
function varargout = gui_Image_Crop_1(varargin)
|
||||||
|
% GUI_IMAGE_CROP_1 MATLAB code for gui_Image_Crop_1.fig
|
||||||
|
% GUI_IMAGE_CROP_1 by itself, creates a new GUI_IMAGE_CROP_1 or raises the
|
||||||
|
% existing singleton*.
|
||||||
|
%
|
||||||
|
% H = GUI_IMAGE_CROP_1 returns the handle to a new GUI_IMAGE_CROP_1 or the handle to
|
||||||
|
% the existing singleton*.
|
||||||
|
%
|
||||||
|
% GUI_IMAGE_CROP_1('CALLBACK',hObject,eventData,handles,...) calls the local
|
||||||
|
% function named CALLBACK in GUI_IMAGE_CROP_1.M with the given input arguments.
|
||||||
|
%
|
||||||
|
% GUI_IMAGE_CROP_1('Property','Value',...) creates a new GUI_IMAGE_CROP_1 or raises the
|
||||||
|
% existing singleton*. Starting from the left, property value pairs are
|
||||||
|
% applied to the GUI before gui_Image_Crop_1_OpeningFcn gets called. An
|
||||||
|
% unrecognized property name or invalid value makes property application
|
||||||
|
% stop. All inputs are passed to gui_Image_Crop_1_OpeningFcn via varargin.
|
||||||
|
%
|
||||||
|
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
|
||||||
|
% instance to run (singleton)".
|
||||||
|
%
|
||||||
|
% See also: GUIDE, GUIDATA, GUIHANDLES
|
||||||
|
|
||||||
|
% Edit the above text to modify the response to help gui_Image_Crop_1
|
||||||
|
|
||||||
|
% Last Modified by GUIDE v2.5 02-Aug-2018 19:55:47
|
||||||
|
|
||||||
|
% Begin initialization code - DO NOT EDIT
|
||||||
|
gui_Singleton = 1;
|
||||||
|
gui_State = struct('gui_Name', mfilename, ...
|
||||||
|
'gui_Singleton', gui_Singleton, ...
|
||||||
|
'gui_OpeningFcn', @gui_Image_Crop_1_OpeningFcn, ...
|
||||||
|
'gui_OutputFcn', @gui_Image_Crop_1_OutputFcn, ...
|
||||||
|
'gui_LayoutFcn', [] , ...
|
||||||
|
'gui_Callback', []);
|
||||||
|
if nargin && ischar(varargin{1})
|
||||||
|
gui_State.gui_Callback = str2func(varargin{1});
|
||||||
|
end
|
||||||
|
|
||||||
|
if nargout
|
||||||
|
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
|
||||||
|
else
|
||||||
|
gui_mainfcn(gui_State, varargin{:});
|
||||||
|
end
|
||||||
|
% End initialization code - DO NOT EDIT
|
||||||
|
|
||||||
|
% --- Executes just before gui_Image_Crop_1 is made visible.
|
||||||
|
function gui_Image_Crop_1_OpeningFcn(hObject, eventdata, handles, varargin)
|
||||||
|
% This function has no output args, see OutputFcn.
|
||||||
|
% hObject handle to figure
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
% varargin command line arguments to gui_Image_Crop_1 (see VARARGIN)
|
||||||
|
|
||||||
|
% Choose default command line output for gui_Image_Crop_1
|
||||||
|
handles.output = 'Cancel';
|
||||||
|
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
% Insert custom Title and Text if specified by the user
|
||||||
|
% Hint: when choosing keywords, be sure they are not easily confused
|
||||||
|
% with existing figure properties. See the output of set(figure) for
|
||||||
|
% a list of figure properties.
|
||||||
|
if(nargin > 3)
|
||||||
|
for index = 1:2:(nargin-3),
|
||||||
|
if nargin-3==index, break, end
|
||||||
|
switch lower(varargin{index})
|
||||||
|
case 'title'
|
||||||
|
set(hObject, 'Name', varargin{index+1});
|
||||||
|
case 'string'
|
||||||
|
set(handles.text1, 'String', varargin{index+1});
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
% Determine the position of the dialog - centered on the callback figure
|
||||||
|
% if available, else, centered on the screen
|
||||||
|
FigPos=get(0,'DefaultFigurePosition');
|
||||||
|
OldUnits = get(hObject, 'Units');
|
||||||
|
set(hObject, 'Units', 'pixels');
|
||||||
|
OldPos = get(hObject,'Position');
|
||||||
|
FigWidth = OldPos(3);
|
||||||
|
FigHeight = OldPos(4);
|
||||||
|
if isempty(gcbf)
|
||||||
|
ScreenUnits=get(0,'Units');
|
||||||
|
set(0,'Units','pixels');
|
||||||
|
ScreenSize=get(0,'ScreenSize');
|
||||||
|
set(0,'Units',ScreenUnits);
|
||||||
|
|
||||||
|
FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
|
||||||
|
FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
|
||||||
|
else
|
||||||
|
GCBFOldUnits = get(gcbf,'Units');
|
||||||
|
set(gcbf,'Units','pixels');
|
||||||
|
GCBFPos = get(gcbf,'Position');
|
||||||
|
set(gcbf,'Units',GCBFOldUnits);
|
||||||
|
FigPos(1:2) = [(GCBFPos(1) + GCBFPos(3) / 2) - FigWidth / 2, ...
|
||||||
|
(GCBFPos(2) + GCBFPos(4) / 2) - FigHeight / 2];
|
||||||
|
end
|
||||||
|
FigPos(3:4)=[FigWidth FigHeight];
|
||||||
|
set(hObject, 'Position', FigPos);
|
||||||
|
set(hObject, 'Units', OldUnits);
|
||||||
|
|
||||||
|
% Show a question icon from dialogicons.mat - variables questIconData
|
||||||
|
% and questIconMap
|
||||||
|
load dialogicons.mat
|
||||||
|
|
||||||
|
IconData=questIconData;
|
||||||
|
questIconMap(256,:) = get(handles.figure1, 'Color');
|
||||||
|
IconCMap=questIconMap;
|
||||||
|
|
||||||
|
% Img=image(IconData, 'Parent', handles.axes1);
|
||||||
|
% set(handles.figure1, 'Colormap', IconCMap);
|
||||||
|
|
||||||
|
% set(handles.axes1, ...
|
||||||
|
% 'Visible', 'off', ...
|
||||||
|
% 'YDir' , 'reverse' , ...
|
||||||
|
% 'XLim' , get(Img,'XData'), ...
|
||||||
|
% 'YLim' , get(Img,'YData') ...
|
||||||
|
% );
|
||||||
|
|
||||||
|
% Make the GUI modal
|
||||||
|
set(handles.figure1,'WindowStyle','modal')
|
||||||
|
|
||||||
|
|
||||||
|
handles.image=varargin{1};
|
||||||
|
axes(handles.axes3);cla;imshow(handles.image,[]);
|
||||||
|
|
||||||
|
|
||||||
|
set(handles.push_CANCEL, 'Enable','off');
|
||||||
|
set(handles.push_CROP, 'Enable','off');
|
||||||
|
|
||||||
|
|
||||||
|
message = sprintf('Draw a box over the image to select the ROI');
|
||||||
|
h1=msgbox(message);
|
||||||
|
handles.h1=h1;
|
||||||
|
uiwait(h1);
|
||||||
|
|
||||||
|
% set(handles.push_CANCEL, 'Enable','on');
|
||||||
|
|
||||||
|
handles.LOC =[];
|
||||||
|
handles.output = 'CANCEL';
|
||||||
|
|
||||||
|
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
axes(handles.axes3);cla;imshow(handles.image,[]);
|
||||||
|
h = imrect;
|
||||||
|
% h=0;
|
||||||
|
|
||||||
|
if sum(size(h))>1
|
||||||
|
set(handles.push_CANCEL, 'Enable','on');
|
||||||
|
set(handles.push_CROP, 'Enable','on');
|
||||||
|
handles.h=h;
|
||||||
|
% getPosition(h)
|
||||||
|
guidata(hObject, handles);
|
||||||
|
uiwait(handles.figure1);
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if sum(size(h))==0
|
||||||
|
try, close(handles.h1), catch, end
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
% delete(handles.figure1);
|
||||||
|
% delete(handles.figure1);
|
||||||
|
% figure1_CloseRequestFcn(handles.figure1,eventdata, handles);
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
% --- Outputs from this function are returned to the command line.
|
||||||
|
function varargout = gui_Image_Crop_1_OutputFcn(hObject, eventdata, handles)
|
||||||
|
% varargout cell array for returning output args (see VARARGOUT);
|
||||||
|
% hObject handle to figure
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
% Get default command line output from handles structure
|
||||||
|
varargout{1} = handles.output;
|
||||||
|
varargout{2} = handles.LOC;
|
||||||
|
% guidata(hObject, handles);
|
||||||
|
% The figure can be deleted now
|
||||||
|
delete(handles.figure1);
|
||||||
|
|
||||||
|
% --- Executes on button press in push_CROP.
|
||||||
|
function push_CROP_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to push_CROP (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
handles.output = get(hObject,'String');
|
||||||
|
|
||||||
|
|
||||||
|
handles.LOC=getPosition(handles.h);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
% Use UIRESUME instead of delete because the OutputFcn needs
|
||||||
|
% to get the updated handles structure.
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
|
||||||
|
% --- Executes on button press in push_CANCEL.
|
||||||
|
function push_CANCEL_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to push_CANCEL (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
handles.output = get(hObject,'String');
|
||||||
|
|
||||||
|
handles.LOC= [];
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
% Use UIRESUME instead of delete because the OutputFcn needs
|
||||||
|
% to get the updated handles structure.
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes when user attempts to close figure1.
|
||||||
|
function figure1_CloseRequestFcn(hObject, eventdata, handles)
|
||||||
|
% % % % % hObject handle to figure1 (see GCBO)
|
||||||
|
% % % % % eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% % % % % handles structure with handles and user data (see GUIDATA)
|
||||||
|
% % % %
|
||||||
|
% % % % if isequal(get(hObject, 'waitstatus'), 'waiting')
|
||||||
|
% % % % % The GUI is still in UIWAIT, us UIRESUME
|
||||||
|
% % % % try close(handles.h1), catch, end
|
||||||
|
% % % % uiresume(hObject);
|
||||||
|
% % % % else
|
||||||
|
% % % % % The GUI is no longer waiting, just close it
|
||||||
|
% % % % try close(handles.h1), catch, end
|
||||||
|
% % % % delete(hObject);
|
||||||
|
% % % % end
|
||||||
|
try close(handles.h1), catch, end
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on key press over figure1 with no controls selected.
|
||||||
|
function figure1_KeyPressFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to figure1 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
% Check for "enter" or "escape"
|
||||||
|
if isequal(get(hObject,'CurrentKey'),'escape')
|
||||||
|
% User said no by hitting escape
|
||||||
|
handles.output = 'CANCEL';
|
||||||
|
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
end
|
||||||
|
|
||||||
|
if isequal(get(hObject,'CurrentKey'),'return')
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on button press in push_RESET.
|
||||||
|
function push_RESET_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to push_RESET (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
338
src/dic/gui_ask_cal_KNOWN_Point.m
Normal file
@@ -0,0 +1,338 @@
|
|||||||
|
function varargout = gui_ask_cal_KNOWN_Point(varargin)
|
||||||
|
% GUI_ASK_CAL_KNOWN_POINT MATLAB code for gui_ask_cal_KNOWN_Point.fig
|
||||||
|
% GUI_ASK_CAL_KNOWN_POINT by itself, creates a new GUI_ASK_CAL_KNOWN_POINT or raises the
|
||||||
|
% existing singleton*.
|
||||||
|
%
|
||||||
|
% H = GUI_ASK_CAL_KNOWN_POINT returns the handle to a new GUI_ASK_CAL_KNOWN_POINT or the handle to
|
||||||
|
% the existing singleton*.
|
||||||
|
%
|
||||||
|
% GUI_ASK_CAL_KNOWN_POINT('CALLBACK',hObject,eventData,handles,...) calls the local
|
||||||
|
% function named CALLBACK in GUI_ASK_CAL_KNOWN_POINT.M with the given input arguments.
|
||||||
|
%
|
||||||
|
% GUI_ASK_CAL_KNOWN_POINT('Property','Value',...) creates a new GUI_ASK_CAL_KNOWN_POINT or raises the
|
||||||
|
% existing singleton*. Starting from the left, property value pairs are
|
||||||
|
% applied to the GUI before gui_ask_cal_KNOWN_Point_OpeningFcn gets called. An
|
||||||
|
% unrecognized property name or invalid value makes property application
|
||||||
|
% stop. All inputs are passed to gui_ask_cal_KNOWN_Point_OpeningFcn via varargin.
|
||||||
|
%
|
||||||
|
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
|
||||||
|
% instance to run (singleton)".
|
||||||
|
%
|
||||||
|
% See also: GUIDE, GUIDATA, GUIHANDLES
|
||||||
|
|
||||||
|
% Edit the above text to modify the response to help gui_ask_cal_KNOWN_Point
|
||||||
|
|
||||||
|
% Last Modified by GUIDE v2.5 03-Aug-2018 03:25:03
|
||||||
|
|
||||||
|
% Begin initialization code - DO NOT EDIT
|
||||||
|
gui_Singleton = 1;
|
||||||
|
gui_State = struct('gui_Name', mfilename, ...
|
||||||
|
'gui_Singleton', gui_Singleton, ...
|
||||||
|
'gui_OpeningFcn', @gui_ask_cal_KNOWN_Point_OpeningFcn, ...
|
||||||
|
'gui_OutputFcn', @gui_ask_cal_KNOWN_Point_OutputFcn, ...
|
||||||
|
'gui_LayoutFcn', [] , ...
|
||||||
|
'gui_Callback', []);
|
||||||
|
if nargin && ischar(varargin{1})
|
||||||
|
gui_State.gui_Callback = str2func(varargin{1});
|
||||||
|
end
|
||||||
|
|
||||||
|
if nargout
|
||||||
|
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
|
||||||
|
else
|
||||||
|
gui_mainfcn(gui_State, varargin{:});
|
||||||
|
end
|
||||||
|
% End initialization code - DO NOT EDIT
|
||||||
|
|
||||||
|
% --- Executes just before gui_ask_cal_KNOWN_Point is made visible.
|
||||||
|
function gui_ask_cal_KNOWN_Point_OpeningFcn(hObject, eventdata, handles, varargin)
|
||||||
|
% This function has no output args, see OutputFcn.
|
||||||
|
% hObject handle to figure
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
% varargin command line arguments to gui_ask_cal_KNOWN_Point (see VARARGIN)
|
||||||
|
|
||||||
|
% Choose default command line output for gui_ask_cal_KNOWN_Point
|
||||||
|
handles.output = 'Cancel';
|
||||||
|
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
% Insert custom Title and Text if specified by the user
|
||||||
|
% Hint: when choosing keywords, be sure they are not easily confused
|
||||||
|
% with existing figure properties. See the output of set(figure) for
|
||||||
|
% a list of figure properties.
|
||||||
|
if(nargin > 3)
|
||||||
|
for index = 1:2:(nargin-3),
|
||||||
|
if nargin-3==index, break, end
|
||||||
|
switch lower(varargin{index})
|
||||||
|
case 'title'
|
||||||
|
set(hObject, 'Name', varargin{index+1});
|
||||||
|
case 'string'
|
||||||
|
set(handles.text1, 'String', varargin{index+1});
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
% Determine the position of the dialog - centered on the callback figure
|
||||||
|
% if available, else, centered on the screen
|
||||||
|
FigPos=get(0,'DefaultFigurePosition');
|
||||||
|
OldUnits = get(hObject, 'Units');
|
||||||
|
set(hObject, 'Units', 'pixels');
|
||||||
|
OldPos = get(hObject,'Position');
|
||||||
|
FigWidth = OldPos(3);
|
||||||
|
FigHeight = OldPos(4);
|
||||||
|
if isempty(gcbf)
|
||||||
|
ScreenUnits=get(0,'Units');
|
||||||
|
set(0,'Units','pixels');
|
||||||
|
ScreenSize=get(0,'ScreenSize');
|
||||||
|
set(0,'Units',ScreenUnits);
|
||||||
|
|
||||||
|
FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
|
||||||
|
FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
|
||||||
|
else
|
||||||
|
GCBFOldUnits = get(gcbf,'Units');
|
||||||
|
set(gcbf,'Units','pixels');
|
||||||
|
GCBFPos = get(gcbf,'Position');
|
||||||
|
set(gcbf,'Units',GCBFOldUnits);
|
||||||
|
FigPos(1:2) = [(GCBFPos(1) + GCBFPos(3) / 2) - FigWidth / 2, ...
|
||||||
|
(GCBFPos(2) + GCBFPos(4) / 2) - FigHeight / 2];
|
||||||
|
end
|
||||||
|
FigPos(3:4)=[FigWidth FigHeight];
|
||||||
|
set(hObject, 'Position', FigPos);
|
||||||
|
set(hObject, 'Units', OldUnits);
|
||||||
|
|
||||||
|
% Show a question icon from dialogicons.mat - variables questIconData
|
||||||
|
% and questIconMap
|
||||||
|
% load dialogicons.mat
|
||||||
|
%
|
||||||
|
% IconData=questIconData;
|
||||||
|
% questIconMap(256,:) = get(handles.figure1, 'Color');
|
||||||
|
% IconCMap=questIconMap;
|
||||||
|
%
|
||||||
|
% % Img=image(IconData, 'Parent', handles.axes1);
|
||||||
|
% set(handles.figure1, 'Colormap', IconCMap);
|
||||||
|
%
|
||||||
|
% set(handles.axes1, ...
|
||||||
|
% 'Visible', 'off', ...
|
||||||
|
% 'YDir' , 'reverse' , ...
|
||||||
|
% 'XLim' , get(Img,'XData'), ...
|
||||||
|
% 'YLim' , get(Img,'YData') ...
|
||||||
|
% );
|
||||||
|
|
||||||
|
% Make the GUI modal
|
||||||
|
set(handles.figure1,'WindowStyle','modal')
|
||||||
|
|
||||||
|
set(handles.push_SET, 'Enable','off');
|
||||||
|
set(handles.edit1, 'Enable','off');
|
||||||
|
set(handles.push_CANCEL, 'Enable','off');
|
||||||
|
|
||||||
|
handles.value=0;
|
||||||
|
handles.image=varargin{1};
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
axes(handles.axes3); imshow(handles.image,[]);
|
||||||
|
get_coordinates1(hObject, eventdata, handles);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
% UIWAIT makes gui_ask_cal_KNOWN_Point wait for user response (see UIRESUME)
|
||||||
|
uiwait(handles.figure1);
|
||||||
|
|
||||||
|
|
||||||
|
function get_coordinates1(hObject, eventdata, handles)
|
||||||
|
|
||||||
|
xx=[];
|
||||||
|
yy=[];
|
||||||
|
iter=0;
|
||||||
|
|
||||||
|
% clf
|
||||||
|
% axes(handles.axes1); imshow(handles.image,[]);
|
||||||
|
|
||||||
|
|
||||||
|
while 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[x y button]=ginput(1);
|
||||||
|
|
||||||
|
% if button==27
|
||||||
|
% xx=[];
|
||||||
|
% yy=[];
|
||||||
|
% iter=0;
|
||||||
|
% end
|
||||||
|
%
|
||||||
|
|
||||||
|
if button==3
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if iter==2,
|
||||||
|
xx=xx(end); yy=yy(end);
|
||||||
|
iter=1;
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
xx=[xx;x];
|
||||||
|
yy=[yy;y];
|
||||||
|
iter=iter+1;
|
||||||
|
|
||||||
|
|
||||||
|
imshow(handles.image,[]),
|
||||||
|
h=line(xx,yy);
|
||||||
|
h.LineWidth=2;
|
||||||
|
h.Color=[1 0 0];
|
||||||
|
pause(0.2)
|
||||||
|
|
||||||
|
if iter==2, break; end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
set(handles.push_SET, 'Enable','on');
|
||||||
|
set(handles.edit1, 'Enable','on');
|
||||||
|
set(handles.push_CANCEL, 'Enable','on');
|
||||||
|
set(handles.text_DISPLAY, 'String',num2str(handles.value));
|
||||||
|
|
||||||
|
|
||||||
|
handles.xx=xx(end-1:end);
|
||||||
|
handles.yy=yy(end-1:end);
|
||||||
|
varargout{2}=handles.xx;
|
||||||
|
varargout{3}=handles.yy;
|
||||||
|
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
|
||||||
|
% --- Outputs from this function are returned to the command line.
|
||||||
|
function varargout = gui_ask_cal_KNOWN_Point_OutputFcn(hObject, eventdata, handles)
|
||||||
|
% varargout cell array for returning output args (see VARARGOUT);
|
||||||
|
% hObject handle to figure
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
% Get default command line output from handles structure
|
||||||
|
varargout{1} = handles.output;
|
||||||
|
varargout{2}=handles.xx;
|
||||||
|
varargout{3}=handles.yy;
|
||||||
|
varargout{4}=handles.value;
|
||||||
|
% The figure can be deleted now
|
||||||
|
delete(handles.figure1);
|
||||||
|
|
||||||
|
% --- Executes on button press in push_SET.
|
||||||
|
function push_SET_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to push_SET (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
handles.output = get(hObject,'String');
|
||||||
|
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
% Use UIRESUME instead of delete because the OutputFcn needs
|
||||||
|
% to get the updated handles structure.
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
|
||||||
|
% --- Executes on button press in push_CANCEL.
|
||||||
|
function push_CANCEL_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to push_CANCEL (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
handles.output = get(hObject,'String');
|
||||||
|
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
% Use UIRESUME instead of delete because the OutputFcn needs
|
||||||
|
% to get the updated handles structure.
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes when user attempts to close figure1.
|
||||||
|
function figure1_CloseRequestFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to figure1 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
if isequal(get(hObject, 'waitstatus'), 'waiting')
|
||||||
|
% The GUI is still in UIWAIT, us UIRESUME
|
||||||
|
uiresume(hObject);
|
||||||
|
else
|
||||||
|
% The GUI is no longer waiting, just close it
|
||||||
|
delete(hObject);
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on key press over figure1 with no controls selected.
|
||||||
|
function figure1_KeyPressFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to figure1 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
% Check for "enter" or "escape"
|
||||||
|
if isequal(get(hObject,'CurrentKey'),'escape')
|
||||||
|
% User said no by hitting escape
|
||||||
|
handles.output = 'No';
|
||||||
|
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
end
|
||||||
|
|
||||||
|
if isequal(get(hObject,'CurrentKey'),'return')
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function edit1_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to edit1 (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 edit1 as text
|
||||||
|
% str2double(get(hObject,'String')) returns contents of edit1 as a double
|
||||||
|
value = str2double(get(hObject,'String')) ;
|
||||||
|
|
||||||
|
if(isnan(value)), handles.value=0; end
|
||||||
|
if(~isnan(value)), handles.value=value; end
|
||||||
|
set(handles.text_DISPLAY, 'String',num2str(handles.value));
|
||||||
|
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes during object creation, after setting all properties.
|
||||||
|
function edit1_CreateFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to edit1 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
|
||||||
|
set(hObject,'BackgroundColor','white');
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on button press in push_RESET.
|
||||||
|
function push_RESET_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to push_RESET (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
set(handles.push_SET, 'Enable','off');
|
||||||
|
set(handles.edit1, 'Enable','off');
|
||||||
|
|
||||||
|
imshow(handles.image,[]),
|
||||||
|
get_coordinates1(hObject, eventdata, handles)
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes during object creation, after setting all properties.
|
||||||
|
function text_DISPLAY_CreateFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to text_DISPLAY (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles empty - handles not created until after all CreateFcns called
|
||||||
289
src/dic/gui_ask_calibration1.m
Normal file
@@ -0,0 +1,289 @@
|
|||||||
|
function varargout = gui_ask_calibration1(varargin)
|
||||||
|
% GUI_ASK_CALIBRATION1 MATLAB code for gui_ask_calibration1.fig
|
||||||
|
% GUI_ASK_CALIBRATION1 by itself, creates a new GUI_ASK_CALIBRATION1 or raises the
|
||||||
|
% existing singleton*.
|
||||||
|
%
|
||||||
|
% H = GUI_ASK_CALIBRATION1 returns the handle to a new GUI_ASK_CALIBRATION1 or the handle to
|
||||||
|
% the existing singleton*.
|
||||||
|
%
|
||||||
|
% GUI_ASK_CALIBRATION1('CALLBACK',hObject,eventData,handles,...) calls the local
|
||||||
|
% function named CALLBACK in GUI_ASK_CALIBRATION1.M with the given input arguments.
|
||||||
|
%
|
||||||
|
% GUI_ASK_CALIBRATION1('Property','Value',...) creates a new GUI_ASK_CALIBRATION1 or raises the
|
||||||
|
% existing singleton*. Starting from the left, property value pairs are
|
||||||
|
% applied to the GUI before gui_ask_calibration1_OpeningFcn gets called. An
|
||||||
|
% unrecognized property name or invalid value makes property application
|
||||||
|
% stop. All inputs are passed to gui_ask_calibration1_OpeningFcn via varargin.
|
||||||
|
%
|
||||||
|
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
|
||||||
|
% instance to run (singleton)".
|
||||||
|
%
|
||||||
|
% See also: GUIDE, GUIDATA, GUIHANDLES
|
||||||
|
|
||||||
|
% Edit the above text to modify the response to help gui_ask_calibration1
|
||||||
|
|
||||||
|
% Last Modified by GUIDE v2.5 10-May-2018 13:04:12
|
||||||
|
|
||||||
|
% Begin initialization code - DO NOT EDIT
|
||||||
|
gui_Singleton = 1;
|
||||||
|
gui_State = struct('gui_Name', mfilename, ...
|
||||||
|
'gui_Singleton', gui_Singleton, ...
|
||||||
|
'gui_OpeningFcn', @gui_ask_calibration1_OpeningFcn, ...
|
||||||
|
'gui_OutputFcn', @gui_ask_calibration1_OutputFcn, ...
|
||||||
|
'gui_LayoutFcn', [] , ...
|
||||||
|
'gui_Callback', []);
|
||||||
|
if nargin && ischar(varargin{1})
|
||||||
|
gui_State.gui_Callback = str2func(varargin{1});
|
||||||
|
end
|
||||||
|
|
||||||
|
if nargout
|
||||||
|
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
|
||||||
|
else
|
||||||
|
gui_mainfcn(gui_State, varargin{:});
|
||||||
|
end
|
||||||
|
% End initialization code - DO NOT EDIT
|
||||||
|
|
||||||
|
% --- Executes just before gui_ask_calibration1 is made visible.
|
||||||
|
function gui_ask_calibration1_OpeningFcn(hObject, eventdata, handles, varargin)
|
||||||
|
% This function has no output args, see OutputFcn.
|
||||||
|
% hObject handle to figure
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
% varargin command line arguments to gui_ask_calibration1 (see VARARGIN)
|
||||||
|
|
||||||
|
% Choose default command line output for gui_ask_calibration1
|
||||||
|
handles.output = 'Yes';
|
||||||
|
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
% Insert custom Title and Text if specified by the user
|
||||||
|
% Hint: when choosing keywords, be sure they are not easily confused
|
||||||
|
% with existing figure properties. See the output of set(figure) for
|
||||||
|
% a list of figure properties.
|
||||||
|
if(nargin > 3)
|
||||||
|
for index = 1:2:(nargin-3),
|
||||||
|
if nargin-3==index, break, end
|
||||||
|
switch lower(varargin{index})
|
||||||
|
case 'title'
|
||||||
|
set(hObject, 'Name', varargin{index+1});
|
||||||
|
case 'string'
|
||||||
|
set(handles.text1, 'String', varargin{index+1});
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
% Determine the position of the dialog - centered on the callback figure
|
||||||
|
% if available, else, centered on the screen
|
||||||
|
FigPos=get(0,'DefaultFigurePosition');
|
||||||
|
OldUnits = get(hObject, 'Units');
|
||||||
|
set(hObject, 'Units', 'pixels');
|
||||||
|
OldPos = get(hObject,'Position');
|
||||||
|
FigWidth = OldPos(3);
|
||||||
|
FigHeight = OldPos(4);
|
||||||
|
if isempty(gcbf)
|
||||||
|
ScreenUnits=get(0,'Units');
|
||||||
|
set(0,'Units','pixels');
|
||||||
|
ScreenSize=get(0,'ScreenSize');
|
||||||
|
set(0,'Units',ScreenUnits);
|
||||||
|
|
||||||
|
FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
|
||||||
|
FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
|
||||||
|
else
|
||||||
|
GCBFOldUnits = get(gcbf,'Units');
|
||||||
|
set(gcbf,'Units','pixels');
|
||||||
|
GCBFPos = get(gcbf,'Position');
|
||||||
|
set(gcbf,'Units',GCBFOldUnits);
|
||||||
|
FigPos(1:2) = [(GCBFPos(1) + GCBFPos(3) / 2) - FigWidth / 2, ...
|
||||||
|
(GCBFPos(2) + GCBFPos(4) / 2) - FigHeight / 2];
|
||||||
|
end
|
||||||
|
FigPos(3:4)=[FigWidth FigHeight];
|
||||||
|
set(hObject, 'Position', FigPos);
|
||||||
|
set(hObject, 'Units', OldUnits);
|
||||||
|
|
||||||
|
% Show a question icon from dialogicons.mat - variables questIconData
|
||||||
|
% and questIconMap
|
||||||
|
load dialogicons.mat
|
||||||
|
|
||||||
|
IconData=questIconData;
|
||||||
|
questIconMap(256,:) = get(handles.figure1, 'Color');
|
||||||
|
IconCMap=questIconMap;
|
||||||
|
|
||||||
|
% Img=image(IconData, 'Parent', handles.axes1);
|
||||||
|
% % % % % % Img=imshow(varargin{1}, 'Parent', handles.axes1);
|
||||||
|
% % % % % % % set(handles.figure1, 'Colormap', IconCMap);
|
||||||
|
% % % % % %
|
||||||
|
% % % % % % set(handles.axes1, ...
|
||||||
|
% % % % % % 'Visible', 'off', ...
|
||||||
|
% % % % % % 'YDir' , 'reverse' , ...
|
||||||
|
% % % % % % 'XLim' , get(Img,'XData'), ...
|
||||||
|
% % % % % % 'YLim' , get(Img,'YData') ...
|
||||||
|
% % % % % % );
|
||||||
|
|
||||||
|
% Make the GUI modal
|
||||||
|
set(handles.figure1,'WindowStyle','modal')
|
||||||
|
|
||||||
|
% [xx, yy]= get_coordinates(varargin{1});
|
||||||
|
|
||||||
|
handles.image=varargin{1};
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
axes(handles.axes1); imshow(handles.image,[]);
|
||||||
|
get_coordinates1(hObject, eventdata, handles);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
% UIWAIT makes gui_ask_calibration1 wait for user response (see UIRESUME)
|
||||||
|
uiwait(handles.figure1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function get_coordinates1(hObject, eventdata, handles)
|
||||||
|
|
||||||
|
xx=[];
|
||||||
|
yy=[];
|
||||||
|
iter=0;
|
||||||
|
|
||||||
|
% clf
|
||||||
|
% axes(handles.axes1); imshow(handles.image,[]);
|
||||||
|
|
||||||
|
|
||||||
|
while 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[x y button]=ginput(1);
|
||||||
|
|
||||||
|
% if button==27
|
||||||
|
% xx=[];
|
||||||
|
% yy=[];
|
||||||
|
% iter=0;
|
||||||
|
% end
|
||||||
|
%
|
||||||
|
|
||||||
|
if button==3
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if iter==2,
|
||||||
|
xx=xx(end); yy=yy(end);
|
||||||
|
iter=1;
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
xx=[xx;x];
|
||||||
|
yy=[yy;y];
|
||||||
|
iter=iter+1;
|
||||||
|
|
||||||
|
|
||||||
|
imshow(handles.image,[]),
|
||||||
|
h=line(xx,yy);
|
||||||
|
h.LineWidth=2;
|
||||||
|
h.Color=[1 0 0];
|
||||||
|
pause(0.2)
|
||||||
|
|
||||||
|
if iter==2, break; end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
handles.xx=xx(end-1:end);
|
||||||
|
handles.yy=yy(end-1:end);
|
||||||
|
varargout{2}=handles.xx;
|
||||||
|
varargout{3}=handles.yy;
|
||||||
|
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
|
||||||
|
% --- Outputs from this function are returned to the command line.
|
||||||
|
function varargout = gui_ask_calibration1_OutputFcn(hObject, eventdata, handles)
|
||||||
|
% varargout cell array for returning output args (see VARARGOUT);
|
||||||
|
% hObject handle to figure
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
% Get default command line output from handles structure
|
||||||
|
varargout{1} = handles.output;
|
||||||
|
varargout{2}=handles.xx;
|
||||||
|
varargout{3}=handles.yy;
|
||||||
|
% The figure can be deleted now
|
||||||
|
delete(handles.figure1);
|
||||||
|
|
||||||
|
% --- Executes on button press in pushbutton1.
|
||||||
|
function pushbutton1_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to pushbutton1 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
handles.output = get(hObject,'String');
|
||||||
|
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
% Use UIRESUME instead of delete because the OutputFcn needs
|
||||||
|
% to get the updated handles structure.
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
|
||||||
|
% --- Executes on button press in pushbutton2.
|
||||||
|
function pushbutton2_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to pushbutton2 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
handles.output = get(hObject,'String');
|
||||||
|
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
% Use UIRESUME instead of delete because the OutputFcn needs
|
||||||
|
% to get the updated handles structure.
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes when user attempts to close figure1.
|
||||||
|
function figure1_CloseRequestFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to figure1 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
if isequal(get(hObject, 'waitstatus'), 'waiting')
|
||||||
|
% The GUI is still in UIWAIT, us UIRESUME
|
||||||
|
uiresume(hObject);
|
||||||
|
else
|
||||||
|
% The GUI is no longer waiting, just close it
|
||||||
|
% % % delete(hObject);
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on key press over figure1 with no controls selected.
|
||||||
|
function figure1_KeyPressFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to figure1 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
% Check for "enter" or "escape"
|
||||||
|
if isequal(get(hObject,'CurrentKey'),'escape')
|
||||||
|
% User said no by hitting escape
|
||||||
|
handles.output = 'No';
|
||||||
|
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
end
|
||||||
|
|
||||||
|
if isequal(get(hObject,'CurrentKey'),'return')
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on button press in pushbutton3.
|
||||||
|
function pushbutton3_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to pushbutton3 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
imshow(handles.image,[]),
|
||||||
|
get_coordinates1(hObject, eventdata, handles)
|
||||||
268
src/dic/gui_confirm_DICstart2.m
Normal file
@@ -0,0 +1,268 @@
|
|||||||
|
function [ varargout] = gui_confirm_DICstart2(varargin)
|
||||||
|
% GUI_CONFIRM_DICSTART2 MATLAB code for gui_confirm_DICstart2.fig
|
||||||
|
% GUI_CONFIRM_DICSTART2 by itself, creates a new GUI_CONFIRM_DICSTART2 or raises the
|
||||||
|
% existing singleton*.
|
||||||
|
%
|
||||||
|
% H = GUI_CONFIRM_DICSTART2 returns the handle to a new GUI_CONFIRM_DICSTART2 or the handle to
|
||||||
|
% the existing singleton*.
|
||||||
|
%
|
||||||
|
% GUI_CONFIRM_DICSTART2('CALLBACK',hObject,eventData,handles,...) calls the local
|
||||||
|
% function named CALLBACK in GUI_CONFIRM_DICSTART2.M with the given input arguments.
|
||||||
|
%
|
||||||
|
% GUI_CONFIRM_DICSTART2('Property','Value',...) creates a new GUI_CONFIRM_DICSTART2 or raises the
|
||||||
|
% existing singleton*. Starting from the left, property value pairs are
|
||||||
|
% applied to the GUI before gui_confirm_DICstart2_OpeningFcn gets called. An
|
||||||
|
% unrecognized property name or invalid value makes property application
|
||||||
|
% stop. All inputs are passed to gui_confirm_DICstart2_OpeningFcn via varargin.
|
||||||
|
%
|
||||||
|
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
|
||||||
|
% instance to run (singleton)".
|
||||||
|
%
|
||||||
|
% See also: GUIDE, GUIDATA, GUIHANDLES
|
||||||
|
|
||||||
|
% Edit the above text to modify the response to help gui_confirm_DICstart2
|
||||||
|
|
||||||
|
% Last Modified by GUIDE v2.5 22-May-2018 22:43:57
|
||||||
|
|
||||||
|
% Begin initialization code - DO NOT EDIT
|
||||||
|
gui_Singleton = 1;
|
||||||
|
gui_State = struct('gui_Name', mfilename, ...
|
||||||
|
'gui_Singleton', gui_Singleton, ...
|
||||||
|
'gui_OpeningFcn', @gui_confirm_DICstart2_OpeningFcn, ...
|
||||||
|
'gui_OutputFcn', @gui_confirm_DICstart2_OutputFcn, ...
|
||||||
|
'gui_LayoutFcn', [] , ...
|
||||||
|
'gui_Callback', []);
|
||||||
|
if nargin && ischar(varargin{1})
|
||||||
|
gui_State.gui_Callback = str2func(varargin{1});
|
||||||
|
end
|
||||||
|
|
||||||
|
if nargout
|
||||||
|
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
|
||||||
|
else
|
||||||
|
gui_mainfcn(gui_State, varargin{:});
|
||||||
|
end
|
||||||
|
% End initialization code - DO NOT EDIT
|
||||||
|
|
||||||
|
% --- Executes just before gui_confirm_DICstart2 is made visible.
|
||||||
|
function gui_confirm_DICstart2_OpeningFcn(hObject, eventdata, handles, varargin)
|
||||||
|
% This function has no output args, see OutputFcn.
|
||||||
|
% hObject handle to figure
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
% varargin command line arguments to gui_confirm_DICstart2 (see VARARGIN)
|
||||||
|
|
||||||
|
% Choose default command line output for gui_confirm_DICstart2
|
||||||
|
handles.output = 'Yes';
|
||||||
|
set(handles.edt,'String',varargin{1});
|
||||||
|
handles.destination=varargin{2};
|
||||||
|
% set(handles.edit2,'String',handles.destination);
|
||||||
|
set(handles.text7,'String',handles.destination);
|
||||||
|
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
% Insert custom Title and Text if specified by the user
|
||||||
|
% Hint: when choosing keywords, be sure they are not easily confused
|
||||||
|
% with existing figure properties. See the output of set(figure) for
|
||||||
|
% a list of figure properties.
|
||||||
|
if(nargin > 3)
|
||||||
|
for index = 1:2:(nargin-3),
|
||||||
|
if nargin-3==index, break, end
|
||||||
|
switch lower(varargin{index})
|
||||||
|
case 'title'
|
||||||
|
set(hObject, 'Name', varargin{index+1});
|
||||||
|
case 'string'
|
||||||
|
set(handles.text1, 'String', varargin{index+1});
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
% Determine the position of the dialog - centered on the callback figure
|
||||||
|
% if available, else, centered on the screen
|
||||||
|
FigPos=get(0,'DefaultFigurePosition');
|
||||||
|
OldUnits = get(hObject, 'Units');
|
||||||
|
set(hObject, 'Units', 'pixels');
|
||||||
|
OldPos = get(hObject,'Position');
|
||||||
|
FigWidth = OldPos(3);
|
||||||
|
FigHeight = OldPos(4);
|
||||||
|
if isempty(gcbf)
|
||||||
|
ScreenUnits=get(0,'Units');
|
||||||
|
set(0,'Units','pixels');
|
||||||
|
ScreenSize=get(0,'ScreenSize');
|
||||||
|
set(0,'Units',ScreenUnits);
|
||||||
|
|
||||||
|
FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
|
||||||
|
FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
|
||||||
|
else
|
||||||
|
GCBFOldUnits = get(gcbf,'Units');
|
||||||
|
set(gcbf,'Units','pixels');
|
||||||
|
GCBFPos = get(gcbf,'Position');
|
||||||
|
set(gcbf,'Units',GCBFOldUnits);
|
||||||
|
FigPos(1:2) = [(GCBFPos(1) + GCBFPos(3) / 2) - FigWidth / 2, ...
|
||||||
|
(GCBFPos(2) + GCBFPos(4) / 2) - FigHeight / 2];
|
||||||
|
end
|
||||||
|
FigPos(3:4)=[FigWidth FigHeight];
|
||||||
|
set(hObject, 'Position', FigPos);
|
||||||
|
set(hObject, 'Units', OldUnits);
|
||||||
|
|
||||||
|
% Show a question icon from dialogicons.mat - variables questIconData
|
||||||
|
% and questIconMap
|
||||||
|
load dialogicons.mat
|
||||||
|
|
||||||
|
IconData=questIconData;
|
||||||
|
questIconMap(256,:) = get(handles.figure1, 'Color');
|
||||||
|
IconCMap=questIconMap;
|
||||||
|
|
||||||
|
Img=image(IconData, 'Parent', handles.axes1);
|
||||||
|
set(handles.figure1, 'Colormap', IconCMap);
|
||||||
|
|
||||||
|
set(handles.axes1, ...
|
||||||
|
'Visible', 'off', ...
|
||||||
|
'YDir' , 'reverse' , ...
|
||||||
|
'XLim' , get(Img,'XData'), ...
|
||||||
|
'YLim' , get(Img,'YData') ...
|
||||||
|
);
|
||||||
|
|
||||||
|
% Make the GUI modal
|
||||||
|
set(handles.figure1,'WindowStyle','modal')
|
||||||
|
|
||||||
|
% UIWAIT makes gui_confirm_DICstart2 wait for user response (see UIRESUME)
|
||||||
|
uiwait(handles.figure1);
|
||||||
|
|
||||||
|
% --- Outputs from this function are returned to the command line.
|
||||||
|
function varargout = gui_confirm_DICstart2_OutputFcn(hObject, eventdata, handles)
|
||||||
|
% varargout cell array for returning output args (see VARARGOUT);
|
||||||
|
% hObject handle to figure
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
% Get default command line output from handles structure
|
||||||
|
try
|
||||||
|
varargout{1} = handles.output;
|
||||||
|
varargout{2} = handles.destination;
|
||||||
|
end
|
||||||
|
% The figure can be deleted now
|
||||||
|
delete(handles.figure1);
|
||||||
|
|
||||||
|
% --- Executes on button press in pushbutton1.
|
||||||
|
function pushbutton1_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to pushbutton1 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
handles.output = get(hObject,'String');
|
||||||
|
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
% Use UIRESUME instead of delete because the OutputFcn needs
|
||||||
|
% to get the updated handles structure.
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
|
||||||
|
% --- Executes on button press in pushbutton2.
|
||||||
|
function pushbutton2_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to pushbutton2 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
handles.output = get(hObject,'String');
|
||||||
|
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
% Use UIRESUME instead of delete because the OutputFcn needs
|
||||||
|
% to get the updated handles structure.
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes when user attempts to close figure1.
|
||||||
|
function figure1_CloseRequestFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to figure1 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
if isequal(get(hObject, 'waitstatus'), 'waiting')
|
||||||
|
% The GUI is still in UIWAIT, us UIRESUME
|
||||||
|
uiresume(hObject);
|
||||||
|
else
|
||||||
|
% The GUI is no longer waiting, just close it
|
||||||
|
delete(hObject);
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on key press over figure1 with no controls selected.
|
||||||
|
function figure1_KeyPressFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to figure1 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
% Check for "enter" or "escape"
|
||||||
|
if isequal(get(hObject,'CurrentKey'),'escape')
|
||||||
|
% User said no by hitting escape
|
||||||
|
handles.output = 'No';
|
||||||
|
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
end
|
||||||
|
|
||||||
|
if isequal(get(hObject,'CurrentKey'),'return')
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
% 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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
|
||||||
|
% set(hObject,'BackgroundColor','white');
|
||||||
|
% end
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on button press in push_set_path.
|
||||||
|
function push_set_path_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to push_set_path (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
[pathname] = uigetdir(handles.destination,'Select Destination Folder');
|
||||||
|
handles.destination = pathname;
|
||||||
|
|
||||||
|
guidata(hObject, handles);
|
||||||
|
% set(handles.edit2,'String',handles.destination);
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes during object creation, after setting all properties.
|
||||||
|
function edt_CreateFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to edt (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles empty - handles not created until after all CreateFcns called
|
||||||
|
%varargin{:}
|
||||||
|
% set(handles.edt,'String',varargin{1});
|
||||||
|
% guidata(hObject, handles);
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes during object creation, after setting all properties.
|
||||||
|
function text7_CreateFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to text7 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles empty - handles not created until after all CreateFcns called
|
||||||
|
% set(handles.text7,'String',handles.destination);
|
||||||
441
src/dic/gui_set_resolution_3.m
Normal file
@@ -0,0 +1,441 @@
|
|||||||
|
function varargout = gui_set_resolution_3(varargin)
|
||||||
|
% GUI_SET_RESOLUTION_3 MATLAB code for gui_set_resolution_3.fig
|
||||||
|
% GUI_SET_RESOLUTION_3 by itself, creates a new GUI_SET_RESOLUTION_3 or raises the
|
||||||
|
% existing singleton*.
|
||||||
|
%
|
||||||
|
% H = GUI_SET_RESOLUTION_3 returns the handle to a new GUI_SET_RESOLUTION_3 or the handle to
|
||||||
|
% the existing singleton*.
|
||||||
|
%
|
||||||
|
% GUI_SET_RESOLUTION_3('CALLBACK',hObject,eventData,handles,...) calls the local
|
||||||
|
% function named CALLBACK in GUI_SET_RESOLUTION_3.M with the given input arguments.
|
||||||
|
%
|
||||||
|
% GUI_SET_RESOLUTION_3('Property','Value',...) creates a new GUI_SET_RESOLUTION_3 or raises the
|
||||||
|
% existing singleton*. Starting from the left, property value pairs are
|
||||||
|
% applied to the GUI before gui_set_resolution_3_OpeningFcn gets called. An
|
||||||
|
% unrecognized property name or invalid value makes property application
|
||||||
|
% stop. All inputs are passed to gui_set_resolution_3_OpeningFcn via varargin.
|
||||||
|
%
|
||||||
|
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
|
||||||
|
% instance to run (singleton)".
|
||||||
|
%
|
||||||
|
% See also: GUIDE, GUIDATA, GUIHANDLES
|
||||||
|
|
||||||
|
% Edit the above text to modify the response to help gui_set_resolution_3
|
||||||
|
|
||||||
|
% Last Modified by GUIDE v2.5 03-Aug-2018 03:41:41
|
||||||
|
|
||||||
|
% Begin initialization code - DO NOT EDIT
|
||||||
|
gui_Singleton = 1;
|
||||||
|
gui_State = struct('gui_Name', mfilename, ...
|
||||||
|
'gui_Singleton', gui_Singleton, ...
|
||||||
|
'gui_OpeningFcn', @gui_set_resolution_3_OpeningFcn, ...
|
||||||
|
'gui_OutputFcn', @gui_set_resolution_3_OutputFcn, ...
|
||||||
|
'gui_LayoutFcn', [] , ...
|
||||||
|
'gui_Callback', []);
|
||||||
|
if nargin && ischar(varargin{1})
|
||||||
|
gui_State.gui_Callback = str2func(varargin{1});
|
||||||
|
end
|
||||||
|
|
||||||
|
if nargout
|
||||||
|
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
|
||||||
|
else
|
||||||
|
gui_mainfcn(gui_State, varargin{:});
|
||||||
|
end
|
||||||
|
% End initialization code - DO NOT EDIT
|
||||||
|
|
||||||
|
% --- Executes just before gui_set_resolution_3 is made visible.
|
||||||
|
function gui_set_resolution_3_OpeningFcn(hObject, eventdata, handles, varargin)
|
||||||
|
% This function has no output args, see OutputFcn.
|
||||||
|
% hObject handle to figure
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
% varargin command line arguments to gui_set_resolution_3 (see VARARGIN)
|
||||||
|
|
||||||
|
% Choose default command line output for gui_set_resolution_3
|
||||||
|
% handles.output1 = 1;
|
||||||
|
% handles.output1='aadata';
|
||||||
|
handles.output1='1';
|
||||||
|
handles.output2 = '1';
|
||||||
|
handles.output = handles.output1;
|
||||||
|
% set(handles.edit1,'Enable','off');
|
||||||
|
set(handles.radio_from_number,'Value',1);
|
||||||
|
|
||||||
|
handles.path =varargin{2};
|
||||||
|
handles.Ext=varargin{3};
|
||||||
|
% parseInputs(varargin)
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
% Insert custom Title and Text if specified by the user
|
||||||
|
% Hint: when choosing keywords, be sure they are not easily confused
|
||||||
|
% with existing figure properties. See the output of set(figure) for
|
||||||
|
% a list of figure properties.
|
||||||
|
if(nargin > 3)
|
||||||
|
for index = 1:2:(nargin-3),
|
||||||
|
if nargin-3==index, break, end
|
||||||
|
switch lower(varargin{index})
|
||||||
|
case 'title'
|
||||||
|
set(hObject, 'Name', varargin{index+1});
|
||||||
|
case 'string'
|
||||||
|
set(handles.text1, 'String', varargin{index+1});
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
% Determine the position of the dialog - centered on the callback figure
|
||||||
|
% if available, else, centered on the screen
|
||||||
|
FigPos=get(0,'DefaultFigurePosition');
|
||||||
|
OldUnits = get(hObject, 'Units');
|
||||||
|
set(hObject, 'Units', 'pixels');
|
||||||
|
OldPos = get(hObject,'Position');
|
||||||
|
FigWidth = OldPos(3);
|
||||||
|
FigHeight = OldPos(4);
|
||||||
|
if isempty(gcbf)
|
||||||
|
ScreenUnits=get(0,'Units');
|
||||||
|
set(0,'Units','pixels');
|
||||||
|
ScreenSize=get(0,'ScreenSize');
|
||||||
|
set(0,'Units',ScreenUnits);
|
||||||
|
|
||||||
|
FigPos(1)=1/2*(ScreenSize(3)-FigWidth);
|
||||||
|
FigPos(2)=2/3*(ScreenSize(4)-FigHeight);
|
||||||
|
else
|
||||||
|
GCBFOldUnits = get(gcbf,'Units');
|
||||||
|
set(gcbf,'Units','pixels');
|
||||||
|
GCBFPos = get(gcbf,'Position');
|
||||||
|
set(gcbf,'Units',GCBFOldUnits);
|
||||||
|
FigPos(1:2) = [(GCBFPos(1) + GCBFPos(3) / 2) - FigWidth / 2, ...
|
||||||
|
(GCBFPos(2) + GCBFPos(4) / 2) - FigHeight / 2];
|
||||||
|
end
|
||||||
|
FigPos(3:4)=[FigWidth FigHeight];
|
||||||
|
set(hObject, 'Position', FigPos);
|
||||||
|
set(hObject, 'Units', OldUnits);
|
||||||
|
|
||||||
|
% Show a question icon from dialogicons.mat - variables questIconData
|
||||||
|
% and questIconMap
|
||||||
|
load dialogicons.mat;
|
||||||
|
|
||||||
|
IconData=questIconData;
|
||||||
|
questIconMap(256,:) = get(handles.figure1, 'Color');
|
||||||
|
IconCMap=questIconMap;
|
||||||
|
|
||||||
|
Img=image(IconData, 'Parent', handles.axes1);
|
||||||
|
set(handles.figure1, 'Colormap', IconCMap);
|
||||||
|
|
||||||
|
set(handles.axes1, ...
|
||||||
|
'Visible', 'off', ...
|
||||||
|
'YDir' , 'reverse' , ...
|
||||||
|
'XLim' , get(Img,'XData'), ...
|
||||||
|
'YLim' , get(Img,'YData') ...
|
||||||
|
);
|
||||||
|
|
||||||
|
% Make the GUI modal
|
||||||
|
set(handles.figure1,'WindowStyle','modal')
|
||||||
|
|
||||||
|
% UIWAIT makes gui_set_resolution_3 wait for user response (see UIRESUME)
|
||||||
|
uiwait(handles.figure1);
|
||||||
|
|
||||||
|
% --- Outputs from this function are returned to the command line.
|
||||||
|
function varargout = gui_set_resolution_3_OutputFcn(hObject, eventdata, handles)
|
||||||
|
% varargout cell array for returning output args (see VARARGOUT);
|
||||||
|
% hObject handle to figure
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
% Get default command line output from handles structure
|
||||||
|
varargout{1} = handles.output1;
|
||||||
|
varargout{2} = handles.output1;
|
||||||
|
|
||||||
|
% The figure can be deleted now
|
||||||
|
delete(handles.figure1);
|
||||||
|
|
||||||
|
% --- Executes on button press in push_yes.
|
||||||
|
function push_yes_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to push_yes (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
handles.output = handles.output2; %get(hObject,'String');
|
||||||
|
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
% Use UIRESUME instead of delete because the OutputFcn needs
|
||||||
|
% to get the updated handles structure.
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
|
||||||
|
% --- Executes on button press in push_NO.
|
||||||
|
function push_NO_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to push_NO (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
% handles.output = handles.output1; % get(hObject,'String');
|
||||||
|
|
||||||
|
handles.output = 'aadata';
|
||||||
|
handles.output1 = 'aadata';
|
||||||
|
handles.output2 = 'aadata';
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
% Use UIRESUME instead of delete because the OutputFcn needs
|
||||||
|
% to get the updated handles structure.
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes when user attempts to close figure1.
|
||||||
|
function figure1_CloseRequestFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to figure1 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
if isequal(get(hObject, 'waitstatus'), 'waiting')
|
||||||
|
% The GUI is still in UIWAIT, us UIRESUME
|
||||||
|
uiresume(hObject);
|
||||||
|
else
|
||||||
|
% The GUI is no longer waiting, just close it
|
||||||
|
delete(hObject);
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on key press over figure1 with no controls selected.
|
||||||
|
function figure1_KeyPressFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to figure1 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
|
||||||
|
% Check for "enter" or "escape"
|
||||||
|
if isequal(get(hObject,'CurrentKey'),'escape')
|
||||||
|
% User said no by hitting escape
|
||||||
|
handles.output = handles.output1; %'No';
|
||||||
|
|
||||||
|
% Update handles structure
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
end
|
||||||
|
|
||||||
|
if isequal(get(hObject,'CurrentKey'),'return')
|
||||||
|
uiresume(handles.figure1);
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function edit1_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to edit1 (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 edit1 as text
|
||||||
|
% str2double(get(hObject,'String')) returns contents of edit1 as a double
|
||||||
|
handles.output1 = get(hObject,'String');
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
% --- Executes during object creation, after setting all properties.
|
||||||
|
function edit1_CreateFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to edit1 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
|
||||||
|
set(hObject,'BackgroundColor','white');
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes when selected object is changed in uibuttongroup1.
|
||||||
|
function uibuttongroup1_SelectionChangedFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to the selected object in uibuttongroup1
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles structure with handles and user data (see GUIDATA)
|
||||||
|
% handles empty - handles not created until after all CreateFcns called
|
||||||
|
c= get(hObject,'String')
|
||||||
|
|
||||||
|
switch c
|
||||||
|
|
||||||
|
case {'1 pixel ='}
|
||||||
|
set(handles.edit1,'Enable','on');
|
||||||
|
handles.output1= handles.output2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
case 'Calculate from CALIBRATION GRID'
|
||||||
|
|
||||||
|
set(handles.edit1,'Enable','off');
|
||||||
|
set(handles.dis_txt_2, 'String','');
|
||||||
|
|
||||||
|
[filename,pathname, FILTERINDEX] = uigetfile( ...
|
||||||
|
{strcat('*', handles.Ext), strcat(handles.Ext,'-files') }, ...
|
||||||
|
'MultiSelect', 'on', 'Selet the Calibration image', handles.path);
|
||||||
|
handles.ref_file=[];
|
||||||
|
if FILTERINDEX==1
|
||||||
|
handles.ref_file = strcat(pathname, filename);
|
||||||
|
tmp = imread(handles.ref_file );
|
||||||
|
[tmp1, tmp2, tmp3]=gui_ask_calibration1(tmp);
|
||||||
|
else
|
||||||
|
tmp1='Cancel';
|
||||||
|
% set(handles.radio_from_null,'Value',1);
|
||||||
|
handles.output1='1';
|
||||||
|
set(handles.radio_from_number,'Value',1);
|
||||||
|
set(handles.edit1,'Enable','on');
|
||||||
|
% set(handles.radio_from_number,'Value',1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
% tmp1='Cancel';
|
||||||
|
% try
|
||||||
|
% [tmp1, tmp2, tmp3]=gui_ask_calibration1(tmp)
|
||||||
|
% catch
|
||||||
|
% end
|
||||||
|
|
||||||
|
switch tmp1
|
||||||
|
case 'Ok'
|
||||||
|
dst=sqrt((tmp2(1)-tmp2(2)).^2+(tmp3(1)-tmp3(2)).^2);
|
||||||
|
if ~isnan(dst), handles.output1 = 1e6*50e-3/dst;
|
||||||
|
set(handles.dis_tex, 'String', strcat(' 1 pix=' ,num2str(handles.output1),'micrometer'));
|
||||||
|
else handles.output1= handles.output2; end
|
||||||
|
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
case 'Cancel'
|
||||||
|
handles.output1= handles.output2;
|
||||||
|
|
||||||
|
handles.output1='1';
|
||||||
|
set(handles.radio_from_number,'Value',1);
|
||||||
|
set(handles.edit1,'Enable','on');
|
||||||
|
|
||||||
|
guidata(hObject, handles);
|
||||||
|
otherwise
|
||||||
|
handles.output1= handles.output2;
|
||||||
|
handles.output1='1';
|
||||||
|
set(handles.radio_from_number,'Value',1);
|
||||||
|
set(handles.edit1,'Enable','on');
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%===============================================================
|
||||||
|
case 'Calculate from known image'
|
||||||
|
|
||||||
|
set(handles.edit1,'Enable','off');
|
||||||
|
set(handles.dis_tex, 'String','' );
|
||||||
|
|
||||||
|
[filename,pathname, FILTERINDEX] = uigetfile( ...
|
||||||
|
{strcat('*', handles.Ext), strcat(handles.Ext,'-files') }, ...
|
||||||
|
'MultiSelect', 'on', 'Selet the Calibration image', handles.path);
|
||||||
|
handles.ref_file=[];
|
||||||
|
if FILTERINDEX==1
|
||||||
|
handles.ref_file = strcat(pathname, filename);
|
||||||
|
tmp = imread(handles.ref_file );
|
||||||
|
[tmp1, tmp2, tmp3, tmp4]=gui_ask_cal_KNOWN_Point(tmp);
|
||||||
|
else
|
||||||
|
tmp1='Cancel';
|
||||||
|
% set(handles.radio_from_null,'Value',1);
|
||||||
|
handles.output1='1';
|
||||||
|
set(handles.radio_from_number,'Value',1);
|
||||||
|
set(handles.edit1,'Enable','on');
|
||||||
|
% set(handles.radio_from_number,'Value',1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
switch tmp1
|
||||||
|
case 'Set'
|
||||||
|
dst=sqrt((tmp2(1)-tmp2(2)).^2+(tmp3(1)-tmp3(2)).^2);
|
||||||
|
if ~isnan(dst), handles.output1 = 1e6*tmp4/dst;
|
||||||
|
set(handles.dis_txt_2, 'String', strcat(' 1 pix=' ,num2str(handles.output1),'micrometer'));
|
||||||
|
|
||||||
|
else, handles.output1= handles.output2; end
|
||||||
|
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
case 'Cancel'
|
||||||
|
handles.output1= handles.output2;
|
||||||
|
|
||||||
|
handles.output1='1';
|
||||||
|
set(handles.radio_from_number,'Value',1);
|
||||||
|
set(handles.edit1,'Enable','on');
|
||||||
|
|
||||||
|
guidata(hObject, handles);
|
||||||
|
otherwise
|
||||||
|
handles.output1= handles.output2;
|
||||||
|
handles.output1='1';
|
||||||
|
set(handles.radio_from_number,'Value',1);
|
||||||
|
set(handles.edit1,'Enable','on');
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
% figure, imshow(tmp,[])
|
||||||
|
|
||||||
|
otherwise
|
||||||
|
disp('aadata')
|
||||||
|
set(handles.edit1,'Enable','off');
|
||||||
|
handles.output1='aadata';
|
||||||
|
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on button press in radio_from_number.
|
||||||
|
function radio_from_number_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to radio_from_number (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 radio_from_number
|
||||||
|
handles.output1=1;
|
||||||
|
guidata(hObject, handles);
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on button press in radio_from_null.
|
||||||
|
function radio_from_null_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to radio_from_null (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 radio_from_null
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on button press in radio_from_image.
|
||||||
|
function radio_from_image_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to radio_from_image (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 radio_from_image
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes during object creation, after setting all properties.
|
||||||
|
function dis_tex_CreateFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to dis_tex (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles empty - handles not created until after all CreateFcns called
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes on button press in radio_from_KNOWN_IMAGE.
|
||||||
|
function radio_from_KNOWN_IMAGE_Callback(hObject, eventdata, handles)
|
||||||
|
% hObject handle to radio_from_KNOWN_IMAGE (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 radio_from_KNOWN_IMAGE
|
||||||
|
|
||||||
|
|
||||||
|
% --- Executes during object creation, after setting all properties.
|
||||||
|
function dis_txt_2_CreateFcn(hObject, eventdata, handles)
|
||||||
|
% hObject handle to dis_txt_2 (see GCBO)
|
||||||
|
% eventdata reserved - to be defined in a future version of MATLAB
|
||||||
|
% handles empty - handles not created until after all CreateFcns called
|
||||||
80
src/dic/image_background2.m
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
function image_background2(im2, xi,yi,value,dd, tiTl, Tltt, Hpath)
|
||||||
|
|
||||||
|
% load('DIC_vecdata.mat', 'im2', 'xi','yi','U_inp');
|
||||||
|
|
||||||
|
[x11, y11]= meshgrid(min(xi):max(xi),min(yi):max(yi));
|
||||||
|
% [a b]=meshgrid(yi,xi);
|
||||||
|
% F = TriScatteredInterp(b(:),a(:),iu(:),'natural');
|
||||||
|
% ius = F(x11,y11);
|
||||||
|
|
||||||
|
size(x11);
|
||||||
|
|
||||||
|
Yi= y11(:,1)+dd(2);
|
||||||
|
Xi= x11(1,:)++dd(1);
|
||||||
|
|
||||||
|
size(Xi);
|
||||||
|
size(Yi);
|
||||||
|
|
||||||
|
if (size(x11,1)<= size(x11,2))
|
||||||
|
sze=min(numel(Yi),numel(Xi));
|
||||||
|
sze1=max(numel(Yi),numel(Xi));
|
||||||
|
end
|
||||||
|
|
||||||
|
if (size(x11,1)> size(x11,2))
|
||||||
|
sze1=min(numel(Yi),numel(Xi));
|
||||||
|
sze=max(numel(Yi),numel(Xi));
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
iiy=repmat(Yi(:)',1, sze1);
|
||||||
|
tmp=iiy(2)-iiy(1);
|
||||||
|
iiy1= iiy-tmp;
|
||||||
|
|
||||||
|
gridy_patch_i =[iiy;iiy1;iiy1;iiy];
|
||||||
|
|
||||||
|
% size(gridy_patch_i)
|
||||||
|
|
||||||
|
%ix
|
||||||
|
|
||||||
|
tmp=[];
|
||||||
|
for iii=1:numel(Xi)
|
||||||
|
tmp=[tmp repmat(Xi(iii),1,sze)];
|
||||||
|
end
|
||||||
|
|
||||||
|
iix = tmp;
|
||||||
|
|
||||||
|
tmp=Xi(2)-Xi(1);
|
||||||
|
iix1= iix+tmp;
|
||||||
|
|
||||||
|
gridx_patch_i = [iix; iix; iix1;iix1];
|
||||||
|
size(gridx_patch_i);
|
||||||
|
|
||||||
|
data_i_trans = (value(:)'); %transpose from column to row vector
|
||||||
|
size(data_i_trans );
|
||||||
|
|
||||||
|
data_patch = [data_i_trans; data_i_trans; data_i_trans; data_i_trans]; %Same disp grad at four vertices of patch square
|
||||||
|
|
||||||
|
|
||||||
|
fig110=figure; set(fig110, 'Visible', 'off');
|
||||||
|
imshow(im2,[]); colormap('gray')
|
||||||
|
freezeColors, hold on, colormap('jet')
|
||||||
|
|
||||||
|
patch_layer = patch(gridx_patch_i,gridy_patch_i,data_patch,'EdgeColor','none','FaceAlpha',0.5);
|
||||||
|
|
||||||
|
axis ij
|
||||||
|
axis equal
|
||||||
|
|
||||||
|
title( strcat(Tltt,' ', '(Full Frame)'))
|
||||||
|
% title(['Contour plot of ',1,sprintf(' (Current image #: )',10)],...
|
||||||
|
% 'fontsize',10,'fontweight','bold')
|
||||||
|
xlabel('[ X-direction ]', 'fontsize',10,'fontweight','bold')
|
||||||
|
ylabel('[ Y-direction ]', 'fontsize',10,'fontweight','bold')
|
||||||
|
set(gca,'fontsize',10,'layer','top')
|
||||||
|
caxis([min(data_i_trans(:)),max(data_i_trans(:))])
|
||||||
|
h = colorbar('Location','EastOutside');
|
||||||
|
title(h,tiTl, 'fontsize',10)
|
||||||
|
Ttt=strcat('[Full_Frame]',Tltt);
|
||||||
|
saveas(gcf, strcat(Hpath,'\',Ttt))
|
||||||
|
close(fig110)
|
||||||
|
|
||||||
|
|
||||||
52
src/dic/myLogfile.m
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
function myLogfile(destination ,imageORvideo,frame_no,DefaultORcrop, REF_image, method,windo_size,overlap)
|
||||||
|
|
||||||
|
|
||||||
|
% imageORvideo='Image';
|
||||||
|
% frame_no=0;
|
||||||
|
% DefaultORcrop='Full Frame';
|
||||||
|
% REF_image='my';
|
||||||
|
% method='cross correlation';
|
||||||
|
% windo_size=50;
|
||||||
|
% overlap=0.7;
|
||||||
|
p1i=0;
|
||||||
|
%************** Output to file ********************************************
|
||||||
|
% s=cd;s=s(max(find(s=='/'))+1:end);
|
||||||
|
% strcat(destination, 'Logfile.txt' );
|
||||||
|
fid = fopen(strcat(destination, '\Logfile.txt' ), 'wt');
|
||||||
|
strcat(destination, '\Logfile.txt' )
|
||||||
|
% fprintf(fid, '%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f',...
|
||||||
|
% Ms, pt1, T5, p5, rho5, M, p1i, T1i, u1i, rho1i, (Re1i/1e+06), ...
|
||||||
|
% (H/1e+06));
|
||||||
|
% fclose(fid);
|
||||||
|
|
||||||
|
fprintf(fid,'%s\t\t\t\t%s\n%s\t\t\t\t\t%d\n%s\t\t%s\n%s\t\t\t\t\t%s\n %s\t\t\t\t\t%s\n%s\t\t\t\t\t%f\n%s\t\t\t%f\n %s\t\t\t%f\n %s\t\t\t\t%f\n %s\t\t\t\t\t%f\n %s\t\t\t%f\n',...
|
||||||
|
'Types of Processing (Image or Video)', imageORvideo,...
|
||||||
|
'Total Number of Frames', frame_no,...
|
||||||
|
'Image Cropped ?',DefaultORcrop,...
|
||||||
|
'Reference Image',REF_image,...
|
||||||
|
'Method of Processing',method,...
|
||||||
|
'window size',windo_size,...
|
||||||
|
'Overlap',overlap,...
|
||||||
|
'Set IT',p1i,...
|
||||||
|
'Set IT',p1i,...
|
||||||
|
'Set IT',p1i,...
|
||||||
|
'Set IT',p1i,...
|
||||||
|
'Set IT',p1i,...
|
||||||
|
'Set IT',p1i);
|
||||||
|
fclose(fid);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
52
src/dic/myLogfile_more.m
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
function myLogfile(destination ,imageORvideo,frame_no,DefaultORcrop, REF_image, method,windo_size,overlap)
|
||||||
|
|
||||||
|
|
||||||
|
% imageORvideo='Image';
|
||||||
|
% frame_no=0;
|
||||||
|
% DefaultORcrop='Full Frame';
|
||||||
|
% REF_image='my';
|
||||||
|
% method='cross correlation';
|
||||||
|
% windo_size=50;
|
||||||
|
% overlap=0.7;
|
||||||
|
p1i=0;
|
||||||
|
%************** Output to file ********************************************
|
||||||
|
% s=cd;s=s(max(find(s=='/'))+1:end);
|
||||||
|
% strcat(destination, 'Logfile.txt' );
|
||||||
|
fid = fopen(strcat(destination, '\Logfile.txt' ), 'wt');
|
||||||
|
strcat(destination, '\Logfile.txt' )
|
||||||
|
% fprintf(fid, '%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f',...
|
||||||
|
% Ms, pt1, T5, p5, rho5, M, p1i, T1i, u1i, rho1i, (Re1i/1e+06), ...
|
||||||
|
% (H/1e+06));
|
||||||
|
% fclose(fid);
|
||||||
|
|
||||||
|
fprintf(fid,'%s\t\t\t\t%s\n%s\t\t\t\t\t%d\n%s\t\t%s\n%s\t\t\t\t\t%s\n %s\t\t\t\t\t%s\n%s\t\t\t\t\t%f\n%s\t\t\t%f\n %s\t\t\t%f\n %s\t\t\t\t%f\n %s\t\t\t\t\t%f\n %s\t\t\t%f\n',...
|
||||||
|
'Types of Processing (Image or Video)', imageORvideo,...
|
||||||
|
'Total Number of Frames', frame_no,...
|
||||||
|
'Image Cropped ?',DefaultORcrop,...
|
||||||
|
'Reference Image',REF_image,...
|
||||||
|
'This package is written by Biswajit Medhi',method,...
|
||||||
|
'window size',windo_size,...
|
||||||
|
'Overlap',overlap,...
|
||||||
|
'Set IT',p1i,...
|
||||||
|
'Set IT',p1i,...
|
||||||
|
'Set IT',p1i,...
|
||||||
|
'Set IT',p1i,...
|
||||||
|
'Set IT',p1i,...
|
||||||
|
'Set IT',p1i);
|
||||||
|
fclose(fid);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
5
src/dic/preset_image.m
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
function[imr11]= preset_image(imr1)
|
||||||
|
|
||||||
|
if (numel(size(imr1))>2), imr1=rgb2gray(imr1); end
|
||||||
|
imr11 = histeq(imr1);
|
||||||
|
imr11=double(imr11);
|
||||||
282
src/dic/uigetfile_with_preview2.m
Normal file
@@ -0,0 +1,282 @@
|
|||||||
|
function [filename, pathname, filterindex] = uigetfile_with_preview2(filterSpec, prompt, folder,callback, multiSelect)
|
||||||
|
% uigetfile_with_preview - GUI dialog window with a preview panel
|
||||||
|
%
|
||||||
|
% Syntax:
|
||||||
|
% filename = uigetfile_with_preview(filterSpec, prompt, folder, callback, multiSelect)
|
||||||
|
%
|
||||||
|
% Description:
|
||||||
|
% uigetfile_with_preview displays a file-selection dialog with an
|
||||||
|
% integrated preview panel.
|
||||||
|
%
|
||||||
|
% Inputs:
|
||||||
|
% filterSpec - similar to uigetfile's filterSpec. Examples:
|
||||||
|
% 'defaultFile.mat'
|
||||||
|
% '*.mat'
|
||||||
|
% {'MAT files', '*.mat'}
|
||||||
|
% {'Data or m files (*.m,*.mat)', {'m';'mat'}}
|
||||||
|
% prompt - optional dialog prompt (default: 'Select file')
|
||||||
|
% folder - optional default folder (default: current folder)
|
||||||
|
% callback - optional handle to a callback function with the following
|
||||||
|
% interface:
|
||||||
|
% callbackFunction(hPanel, filename)
|
||||||
|
% The callback function should check the specified file and
|
||||||
|
% update the specified panel accordingly.
|
||||||
|
% (default: [])
|
||||||
|
% multiSelect - optional flag specifying whether multiple files can be
|
||||||
|
% selected (default: false)
|
||||||
|
%
|
||||||
|
% Output:
|
||||||
|
% filename - full-path filename of the selected file(s) (or empty array)
|
||||||
|
%
|
||||||
|
% Bugs and suggestions:
|
||||||
|
% Please send to Yair Altman (altmany at gmail dot com)
|
||||||
|
%
|
||||||
|
% Change log:
|
||||||
|
% 2016-11-02: First version posted on <a href="https://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A27420">MathWorks File Exchange</a>
|
||||||
|
%
|
||||||
|
% See also:
|
||||||
|
% uigetfile
|
||||||
|
|
||||||
|
% Programmed by Yair M. Altman: altmany(at)gmail.com
|
||||||
|
% $Revision: 1.0 $ $Date: 2016/11/02 23:43:54 $
|
||||||
|
|
||||||
|
if nargin < 1, filterSpec = {'All files','*.*'}; end
|
||||||
|
if nargin < 2, prompt = ''; end
|
||||||
|
if nargin < 3, folder = pwd; end
|
||||||
|
if nargin < 4, callback = ''; end
|
||||||
|
if nargin < 5, multiSelect = false; end
|
||||||
|
|
||||||
|
% Prepare the figure dialog window
|
||||||
|
if isempty(prompt), prompt = 'Select file'; end
|
||||||
|
hFig = dialog('Name',prompt, 'units','pixel', 'pos',[200,50,500,600]);
|
||||||
|
|
||||||
|
|
||||||
|
% Display the file-selection component
|
||||||
|
javaComponentName = 'javax.swing.JFileChooser'; %#ok<NASGU>
|
||||||
|
javaComponentName = 'com.mathworks.hg.util.dFileChooser'; % this is a MathWorks extension of JFileChooser - no good on Win7
|
||||||
|
%javaComponentName = 'com.mathworks.mwswing.MJFileChooserPerPlatform';
|
||||||
|
[hjFileChooser, hContainer] = javacomponent(javaComponentName, [0,200,500,400], hFig); %#ok<ASGLU>
|
||||||
|
hjFileChooser.setCurrentDirectory(java.io.File(folder));
|
||||||
|
hjFileChooser.setMultiSelectionEnabled(multiSelect);
|
||||||
|
drawnow;
|
||||||
|
|
||||||
|
% Java default background colors are different from Matlab's - fix this
|
||||||
|
%bgcolor = hjFileChooser.Background.getComponents([]);
|
||||||
|
%set(hFig,'color',bgcolor(1:3));
|
||||||
|
bgcolor = get(hFig,'color');
|
||||||
|
hjFileChooser.Background = java.awt.Color(bgcolor(1),bgcolor(2),bgcolor(3));
|
||||||
|
|
||||||
|
% Prepare the allowable file types filter (similar to the uigetfile function)
|
||||||
|
if ~isempty(filterSpec)
|
||||||
|
if ischar(filterSpec)
|
||||||
|
origFilterSpec = filterSpec;
|
||||||
|
[dummy,dummy,ext] = fileparts(filterSpec); %#ok<ASGLU>
|
||||||
|
filterSpec = {[ext(2:end) ' files'], ['*' ext]};
|
||||||
|
if ~any(origFilterSpec=='*')
|
||||||
|
try hjFileChooser.setSelectedFile(java.io.File(origFilterSpec)); catch, end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
hjFileChooser.setAcceptAllFileFilterUsed(false);
|
||||||
|
fileFilter = {};
|
||||||
|
%fileFilter{1} = AddFileFilter(hjFileChooser, 'Data files (*.mat)', {'mat'});
|
||||||
|
%fileFilter{2} = AddFileFilter(hjFileChooser, 'Data or m files (*.m,*.mat)', {'m';'mat'});
|
||||||
|
%fileFilter{3} = AddFileFilter(hjFileChooser, 'All Files', '*.*');
|
||||||
|
for filterIdx = 1 : size(filterSpec,1)
|
||||||
|
fileFilter{end+1} = AddFileFilter(hjFileChooser, filterSpec{filterIdx,:}); %#ok<AGROW>
|
||||||
|
end
|
||||||
|
try
|
||||||
|
hjFileChooser.setFileFilter(fileFilter{1}); % use the first filter by default
|
||||||
|
catch
|
||||||
|
% never mind - ignore...
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
% Prepare the preview panel
|
||||||
|
hPreviewPanel = uipanel('parent',hFig, 'title','Preview', 'tag','PreviewPanel', ...
|
||||||
|
'units','pixel', 'pos',[10,10,480,180], 'Background',bgcolor(1:3));
|
||||||
|
|
||||||
|
% Prepare the figure callbacks
|
||||||
|
hjFileChooser.PropertyChangeCallback = {@PreviewCallback,hPreviewPanel,callback};
|
||||||
|
hjFileChooser.ActionPerformedCallback = {@ActionPerformedCallback,hFig};
|
||||||
|
|
||||||
|
% Key-typed callback
|
||||||
|
try
|
||||||
|
hFn = handle(hjFileChooser.getComponent(2).getComponent(2).getComponent(2).getComponent(1),'CallbackProperties');
|
||||||
|
% hFn should be a javahandle_withcallbacks.com.sun.java.swing.plaf.windows.WindowsFileChooserUI$7
|
||||||
|
hFn.KeyTypedCallback = {@KeyTypedCallback,hjFileChooser};
|
||||||
|
catch
|
||||||
|
% maybe the file-chooser editbox changed location
|
||||||
|
end
|
||||||
|
|
||||||
|
% Wait for user input
|
||||||
|
uiwait(hFig);
|
||||||
|
|
||||||
|
% We get here if the figure is either deleted or Cancel/Open were pressed
|
||||||
|
if ishghandle(hFig)
|
||||||
|
% Open were clicked
|
||||||
|
filename = getappdata(hFig,'selectedFile');
|
||||||
|
close(hFig);
|
||||||
|
else % figure was deleted/closed
|
||||||
|
filename = '';
|
||||||
|
end
|
||||||
|
end % uigetfile_with_preview
|
||||||
|
|
||||||
|
%% Add a file filter type
|
||||||
|
function fileFilter = AddFileFilter(hjFileChooser, description, extension)
|
||||||
|
try
|
||||||
|
if ~iscell(extension)
|
||||||
|
extension = {extension};
|
||||||
|
end
|
||||||
|
if strcmp(extension{1},'*.*') %any(extension{1} == '*')
|
||||||
|
jBasicFileChooserUI = javax.swing.plaf.basic.BasicFileChooserUI(hjFileChooser.java);
|
||||||
|
fileFilter = javaObjectEDT('javax.swing.plaf.basic.BasicFileChooserUI$AcceptAllFileFilter',jBasicFileChooserUI);
|
||||||
|
else
|
||||||
|
extension = regexprep(extension,'^.*\*?\.','');
|
||||||
|
fileFilter = com.mathworks.mwswing.FileExtensionFilter(description, extension, false, true);
|
||||||
|
end
|
||||||
|
javaMethodEDT('addChoosableFileFilter',hjFileChooser,fileFilter);
|
||||||
|
catch
|
||||||
|
% ignore...
|
||||||
|
fileFilter = [];
|
||||||
|
end
|
||||||
|
end % AddFileFilter
|
||||||
|
|
||||||
|
%% Preview callback function
|
||||||
|
function PreviewCallback(hjFileChooser, eventData, hPreviewPanel, callback) %#ok<INUSL>
|
||||||
|
try
|
||||||
|
% Get the selected file
|
||||||
|
filename = char(hjFileChooser.getSelectedFile);
|
||||||
|
if isempty(filename) || ~exist(filename,'file')
|
||||||
|
return; % bail out
|
||||||
|
end
|
||||||
|
|
||||||
|
% Analyze the file based on its type
|
||||||
|
ClearPanel(hPreviewPanel)
|
||||||
|
if isempty(callback) % default callback
|
||||||
|
[fpath,fname,fext] = fileparts(filename); %#ok<ASGLU>
|
||||||
|
switch fext
|
||||||
|
% case '.mat'
|
||||||
|
% % Load the first data element in the file
|
||||||
|
% data = load(filename);
|
||||||
|
% fnames = fieldnames(data);
|
||||||
|
% data = data.(fnames{1});
|
||||||
|
%
|
||||||
|
% % Update the preview panel
|
||||||
|
% hax = axes('Parent',hPreviewPanel, 'units','norm', 'LooseInset',[0,0,0,0]);
|
||||||
|
% plot(hax, data.x, data.y);
|
||||||
|
% box(hax, 'off');
|
||||||
|
|
||||||
|
case '.tif'
|
||||||
|
% Load the first data element in the file
|
||||||
|
data = imread(filename);
|
||||||
|
if (numel(size(data)))<3
|
||||||
|
v=data;
|
||||||
|
v1=zeros([size(v),3]);v1(:,:,1)=v; v1(:,:,2)=v;v1(:,:,3)=v;
|
||||||
|
data=uint8(v1); v1=[]; v=[];
|
||||||
|
end
|
||||||
|
% Update the preview panel
|
||||||
|
hax = axes('Parent',hPreviewPanel, 'units','norm', 'LooseInset',[0,0,0,0]);
|
||||||
|
image(data)
|
||||||
|
%plot(hax, data.x, data.y);
|
||||||
|
box(hax, 'off');
|
||||||
|
case '.tiff'
|
||||||
|
% Load the first data element in the file
|
||||||
|
data = imread(filename);
|
||||||
|
if (numel(size(data)))<3
|
||||||
|
v=data;
|
||||||
|
v1=zeros([size(v),3]);v1(:,:,1)=v; v1(:,:,2)=v;v1(:,:,3)=v;
|
||||||
|
data=uint8(v1); v1=[]; v=[];
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
% Update the preview panel
|
||||||
|
hax = axes('Parent',hPreviewPanel, 'units','norm', 'LooseInset',[0,0,0,0]);
|
||||||
|
image(data)
|
||||||
|
%plot(hax, data.x, data.y);
|
||||||
|
box(hax, 'off');
|
||||||
|
case '.jpg'
|
||||||
|
% Load the first data element in the file
|
||||||
|
data = imread(filename);
|
||||||
|
if (numel(size(data)))<3
|
||||||
|
v=data;
|
||||||
|
v1=zeros([size(v),3]);v1(:,:,1)=v; v1(:,:,2)=v;v1(:,:,3)=v;
|
||||||
|
data=uint8(v1); v1=[]; v=[];
|
||||||
|
end
|
||||||
|
% Update the preview panel
|
||||||
|
hax = axes('Parent',hPreviewPanel, 'units','norm', 'LooseInset',[0,0,0,0]);
|
||||||
|
image(data)
|
||||||
|
%plot(hax, data.x, data.y);
|
||||||
|
box(hax, 'off');
|
||||||
|
|
||||||
|
|
||||||
|
case '.bmp'
|
||||||
|
% Load the first data element in the file
|
||||||
|
data = imread(filename);
|
||||||
|
if (numel(size(data)))<3
|
||||||
|
v=data;
|
||||||
|
v1=zeros([size(v),3]);v1(:,:,1)=v; v1(:,:,2)=v;v1(:,:,3)=v;
|
||||||
|
data=uint8(v1); v1=[]; v=[];
|
||||||
|
end
|
||||||
|
% Update the preview panel
|
||||||
|
hax = axes('Parent',hPreviewPanel, 'units','norm', 'LooseInset',[0,0,0,0]);
|
||||||
|
image(data)
|
||||||
|
%plot(hax, data.x, data.y);
|
||||||
|
box(hax, 'off');
|
||||||
|
|
||||||
|
|
||||||
|
otherwise
|
||||||
|
% Do something useful here...
|
||||||
|
end
|
||||||
|
else % user-specified callback that accepts hPreviewPanel,filename
|
||||||
|
callback(hPreviewPanel,filename);
|
||||||
|
end
|
||||||
|
catch
|
||||||
|
% Never mind - bail out...
|
||||||
|
end
|
||||||
|
end % PreviewCallback
|
||||||
|
|
||||||
|
%% Clear the specified panel
|
||||||
|
function ClearPanel(hPanel)
|
||||||
|
try
|
||||||
|
hObjs = findall(hPanel);
|
||||||
|
hObjs = setdiff(hObjs, findall(hPanel,'string',get(hPanel,'title'))); % keep the title
|
||||||
|
%delete(hObjs(2:end));
|
||||||
|
hObjs = setdiff(hObjs, hPanel); % this is safer...
|
||||||
|
delete(hObjs);
|
||||||
|
catch
|
||||||
|
% ignore...
|
||||||
|
end
|
||||||
|
end % ClearPanel
|
||||||
|
|
||||||
|
%% Figure actions (Cancel & Open)
|
||||||
|
function ActionPerformedCallback(hjFileChooser, eventData, hFig)
|
||||||
|
switch char(eventData.getActionCommand)
|
||||||
|
case 'CancelSelection'
|
||||||
|
close(hFig);
|
||||||
|
|
||||||
|
case 'ApproveSelection'
|
||||||
|
files = cellfun(@char, cell(hjFileChooser.getSelectedFiles), 'uniform',0);
|
||||||
|
%msgbox(['Selected file: ' files{:}], 'Selected!');
|
||||||
|
if numel(files)==1
|
||||||
|
%files = files{1};
|
||||||
|
end
|
||||||
|
if isempty(files)
|
||||||
|
files = char(hjFileChooser.getSelectedFile);
|
||||||
|
end
|
||||||
|
setappdata(hFig,'selectedFile', files);
|
||||||
|
uiresume(hFig);
|
||||||
|
|
||||||
|
otherwise
|
||||||
|
% should never happen
|
||||||
|
end
|
||||||
|
end % ActionPerformedCallback
|
||||||
|
|
||||||
|
%% Key-types callback in the file-name editbox
|
||||||
|
function KeyTypedCallback(hEditbox, eventData, hjFileChooser) %#ok<INUSL>
|
||||||
|
text = char(get(hEditbox,'Text'));
|
||||||
|
[wasFound,idx,unused,folder] = regexp(text,'(.*[:\\/])'); %#ok<ASGLU>
|
||||||
|
if wasFound
|
||||||
|
% This will silently fail if folder does not exist
|
||||||
|
hjFileChooser.setCurrentDirectory(java.io.File(folder));
|
||||||
|
end
|
||||||
|
end
|
||||||
BIN
src/images/IISc_logo1.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
src/images/Shan_Logo1.jpg
Normal file
|
After Width: | Height: | Size: 7.0 KiB |
BIN
src/images/iisc_logo.png
Normal file
|
After Width: | Height: | Size: 53 KiB |
BIN
src/images/lines.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
src/images/p1.png
Normal file
|
After Width: | Height: | Size: 9.1 KiB |