function varargout = SurfSuite2(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @SurfSuite2_OpeningFcn, ...
'gui_OutputFcn', @SurfSuite2_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
function SurfSuite2_OpeningFcn(hObject, ~, handles, varargin)
handles.output = hObject;
handles.xNum = 0;
handles.ynum = 0;
handles.dx = 0;
handles.dy = 0;
handles.Z = 0;
handles.Mag = 0;
handles.filterindex = 0;
handles.filename = 0;
handles.path = 0;
handles.pathname = 0;
handles.SNum = 0;
guidata(hObject, handles);
function varargout = SurfSuite2_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function OpenSurface_Callback(hObject, eventdata, handles)
[filename, pathname, filterindex] = uigetfile( ...
{'*.sdf','sdf-files (*.sdf)'; ...
'*.kos','summit (*.kos)'; ...
'*.al3d','alicona (*.al3d)'; ...
'*.sp','toray (*.sp)'}, ...
'Pick a file');
if filterindex == 0
return
end
path = [pathname filename];
run OpenSurf.m;
run PLot.m;
run FieldParameter.m;
run SurfUpdate.m
guidata(hObject,handles)
function LinearPlane_Callback(hObject, eventdata, handles)
run SurfInfo.m;
run F_LSPlane.m;
run SurfUpdate.m;
run PLot.m;
run FieldParameter.m;
guidata(hObject,handles)
function GLPF_Callback(hObject, eventdata, handles)
run SurfInfo.m;
Lc = str2double(get(handles.Lc1,'String'));
Dx = round (Lc/dx);
Dy = round (Lc/dy);
N = Dx/6;
G = fspecial('gaussian',[Dy,Dx],N);
Z = imfilter(Z,G,'symmetric','same');
run PLot;
run FieldParameter.m;
run SurfUpdate.m;
guidata(hObject,handles)
function GHPF_Callback(hObject, eventdata, handles)
run SurfInfo.m;
Lc = str2double(get(handles.Lc2,'String'));
Dx = round (Lc/dx);
Dy = round (Lc/dy);
N = Dx/6;
G = fspecial('gaussian',[Dy,Dx],N);
Zg = imfilter(Z,G,'symmetric','same');
Z = Z - Zg;
run PLot;
run FieldParameter.m;
run SurfUpdate.m;
guidata(hObject,handles)
function Lc1_Callback(hObject, eventdata, handles)
function Lc1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Lc2_Callback(hObject, eventdata, handles)
function Lc2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function MedFilter_Callback(hObject, eventdata, handles)
run SurfInfo.m;
Lc = str2double(get(handles.Lc3,'String'));
Dx = Lc;
Dy = Lc;
Lext=round(Dx/2)+1;
S=[Lext,Lext];
Z=wextend('2D','sym',Z,Lext);
Z=medfilt2(Z,[Dx Dy]);
Z=Z(1+S(1):end-S(1),1+S(2):end-S(2));
run PLot;
run FieldParameter.m;
run SurfUpdate.m;
guidata(hObject,handles)
function Lc3_Callback(hObject, eventdata, handles)
function Lc3_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Sz_CreateFcn(hObject, eventdata, handles)
function Sq_CreateFcn(hObject, eventdata, handles)
function Ssk_CreateFcn(hObject, eventdata, handles)
function Sku_CreateFcn(hObject, eventdata, handles)
function Sa_CreateFcn(hObject, eventdata, handles)
function edit10_CreateFcn(hObject, eventdata, handles)
function OpenSurfBack_Callback(hObject, eventdata, handles)
filterindex = handles.filterindex;
pathname = sprintf('%s',handles.pathname);
filename = sprintf('%s', handles.filename);
path = strcat(pathname, filename);
run OpenSurf.m;
run PLot.m;
run FieldParameter.m;
run SurfUpdate.m;
guidata(hObject,handles)
function replot_Callback(hObject, eventdata, handles)
run SurfInfo.m;
run PLot.m
function az_Callback(hObject, eventdata, handles)
function az_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function el_Callback(hObject, eventdata, handles)
function el_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function x_ar_Callback(hObject, eventdata, handles)
function x_ar_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function y_ar_Callback(hObject, eventdata, handles)
function y_ar_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function z_ar_Callback(hObject, eventdata, handles)
function z_ar_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function SaveSurface_Callback(hObject, eventdata, handles)
z0 = (handles.Z)/1000000;
dx = double(handles.dx)/1000000;
dy = double(handles.dy)/1000000;
Mag = double(handles.Mag);
run SaveTData.m;
function CropButton_Callback(hObject, eventdata, handles)
run SurfInfo.m;
image(Z);
Z = imcrop;
image(Z);
[m, n]= size(Z);
xNum = n;
yNum = m;
run FieldParameter.m;
run SurfUpdate.m;
guidata(hObject,handles)
function RotateButton_Callback(hObject, eventdata, handles)
run SurfInfo.m;
angle = str2double(get(handles.RotateAngle,'String'));
Z = imrotate(Z, 180);
[m, n]= size(Z);
xNum = n;
yNum = m;
run PLot.m;
run FieldParameter.m;
run SurfUpdate.m;
guidata(hObject,handles);
function RotateAngle_Callback(hObject, eventdata, handles)
function RotateAngle_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function reverse_button_Callback(hObject, eventdata, handles)
run SurfInfo.m;
Z = -Z;
run PLot.m;
run FieldParameter.m;
run SurfUpdate.m;
guidata(hObject,handles)
function FlipY_Callback(hObject, eventdata, handles)
run SurfInfo.m;
Z = flipud(Z);
run PLot.m;
run FieldParameter.m;
run SurfUpdate.m;
guidata(hObject,handles)
function FlipX_Callback(hObject, eventdata, handles)
run SurfInfo.m;
Z = fliplr(Z);
run PLot.m;
run FieldParameter.m;
run SurfUpdate.m;
guidata(hObject,handles)
function re_size_Callback(hObject, eventdata, handles)
run SurfInfo.m;
a = str2double(get(handles.re_size_ratio,'String'));
Z = imresize(Z,a,'nearest');
[m, n]= size(Z);
xNum = n;
yNum = m;
dx = dx/a;
dy = dy/a;
run PLot.m;
run FieldParameter.m;
run SurfUpdate.m;
guidata(hObject,handles)
function re_size_ratio_Callback(hObject, eventdata, handles)
function re_size_ratio_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function OutlierCorrection_Callback(hObject, eventdata, handles)
run SurfInfo.m;
SD = str2double(get(handles.OutlierLevel,'String'));
w = str2double(get(handles.OutlierPixel,'String'));
run YOutlier.m;
run PLot.m;
run FieldParameter.m;
run SurfUpdate.m;
guidata(hObject,handles)
function OutlierLevel_Callback(hObject, eventdata, handles)
function OutlierLevel_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function OutlierPixel_Callback(hObject, eventdata, handles)
function OutlierPixel_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function pushbutton20_Callback(hObject, eventdata, handles)
run SurfInfo.m;
Z = inpaint_nans(Z,5);
run PLot.m;
run FieldParameter.m;
run SurfUpdate.m;
guidata(hObject,handles)
function Untitled_1_Callback(hObject, eventdata, handles)
function ThresholdBtn_Callback(hObject, eventdata, handles)
run SurfInfo.m;
T = str2double(get(handles.ThresholdV,'String'));
Z(Z>=T) = NaN;
run PLot.m;
run FieldParameter.m;
run SurfUpdate.m;
guidata(hObject,handles)
function ThresholdV_Callback(hObject, eventdata, handles)
function ThresholdV_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function RepNanArea_Callback(hObject, eventdata, handles)
run SurfInfo.m;
NanArea = str2double(get(handles.NanArea,'String'));
B = Z;
B(isnan(B)) = min(B(:)) -50;
T = min(B(:)) +10;
BW = imbinarize(B, T);
BW = -BW+1;
BW = ~bwareaopen(BW, NanArea);
Z(BW==0) = min(Z(:))-50;
Z = inpaint_nans(Z,3);
Z(BW==0) = NaN;
run PLot.m;
run FieldParameter.m;
run SurfUpdate.m;
guidata(hObject,handles)
function NanArea_Callback(hObject, eventdata, handles)
function NanArea_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function CropXY_Callback(hObject, eventdata, handles)
run SurfInfo.m;
X1 = str2double(get(handles.CropX1,'String'));
Y1 = str2double(get(handles.CropX2,'String'));
W1 = str2double(get(handles.CropY1,'String'));
H1 = str2double(get(handles.CropY2,'String'));
Z = imcrop(Z,[X1 Y1 W1 H1]);
image(Z);
[m, n]= size(Z);
xNum = n;
yNum = m;
run FieldParameter.m;
run SurfUpdate.m;
run PLot.m;
guidata(hObject,handles)
function CropX1_Callback(hObject, eventdata, handles)
function CropX1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function CropX2_Callback(hObject, eventdata, handles)
function CropX2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function CropY1_Callback(hObject, eventdata, handles)
function CropY1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function CropY2_Callback(hObject, eventdata, handles)
function CropY2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function uipushtool2_ClickedCallback(hObject, eventdata, handles)
F = getframe(handles.axes1);
Image = frame2im(F);
[filename, pathname] = uiputfile(...
{'*.jpg';'*.*'},...
'Save Image Data as');
if filename == 0
return;
end
path = [pathname filename];
imwrite(Image, path);
function axes1_CreateFcn(hObject, eventdata, handles)