1read.m文件为主要显示界面。
点击文件打开SYNVIEWSCAN扫描所得的svd文件,显示样件的三维反射光强图。
此处,选择的X坐标范围为1-190,Y坐标范围为1-140,Z向分层为95(共201,每一层为1mm),可以清晰显示复合材料内部的缺陷。再选择点击显示坐标,可在显示图像上(经灰度直方图拉伸提高对比度后)看到每个像素点的坐标,实现定量分析功能。
本来打算自己创建一个计算面积的方法,后来发现matlab中有一个自带的app叫 Image
Region Analyzer。导入图像可以自动计算每个离散区域的像素面积。但图像必须先阈值分割(color
thresholder),再进行二值化处理,此处不详细展开解释了。
2NDTtext为一个子界面,可以根据它来观察扫描的三维空间内所有点的Z方向波形图。
与之前的界面一样,点击文件,选择一个SVD,输入想观测点的坐标及可得到Z方向波形图。填写图片摘要(选填)
最后,附上我的源码。
第一段read.m
function varargout = read(varargin)
% READ MATLAB code for read.fig
%
READ, by itself, creates a new READ or raises the
existing
%
singleton*.
%
%
H = READ returns the handle to a new READ or the
handle to
%
the existing singleton*.
%
%
READ('CALLBACK',hObject,eventData,handles,...)
calls the local
%
function named CALLBACK in READ.M with the given
input arguments.
%
%
READ('Property','Value',...) creates a new READ
or raises the
%
existing singleton*. Starting
from the left, property value pairs are
%
applied to the GUI before read_OpeningFcn gets
called. An
%
unrecognized property name or invalid value makes
property application
%
stop. All inputs are passed to
read_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
read
% Last Modified by GUIDE v2.5 23-Dec-2015
16:58:44
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton,
...
'gui_OpeningFcn', @read_OpeningFcn,
...
'gui_OutputFcn',
@read_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 read is made
visible.
function read_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
read (see VARARGIN)
% Choose default command line output for read
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes read wait for user response (see
UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the
command line.
function varargout = read_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;
function open_Callback(hObject, eventdata,
handles)
% hObject handle to
open (see GCBO)
% eventdata reserved - to be defined in
a future version of MATLAB
% handles structure
with handles and user data (see GUIDATA)
%-----------------------------1.Pick a file
-------------------------------
[filename, pathname] = uigetfile({
'*.svd','SVD-files(*.svd)'},'Please pick a *.svd file');
file_name_and_path =strcat(pathname,filename);
set(handles.text_filename,'String',file_name_and_path);
if ~(ischar(filename))
%如果没有选取文件则中断程序的执行,
return
%end后的代码失效,
end
%提高程序效率。
%-----------------------------2.Read the file
-----------------------------
%-----------(1)Read header
----------------------------------------------
disp('Loading File ...');
fid=fopen(filename,'r');
%以只读形式打开文件
line_str='';
ii=0;
while ~(strcmp(line_str,'end_of_header'))
ii=ii+1;
line_str=fgetl(fid);
if
~(strcmp(line_str,'end_of_header'))
eval_r([strcat('header',num2str(ii)),'=line_str;']);
end
end
%-----------(2)Read data
------------------------------------------------
%------------ Information
-----------
name='';
while ~(strcmp(name,'end_of_var_list'))
line_str=fgetl(fid);
[name,value] =
strread(line_str,'%s%f');
%name返回的是元胞数组
if
~(strcmp(name,'end_of_var_list'))
eval_r([char(name) '=' num2str(value)
';']);
end
end
%---------------Main data
-------------
NT=t_max-t_min;
[data count]=fread(fid,inf,'*uint8');
fclose(fid);
%----------------------------3.Data pretreatment
--------------------------
data=reshape(data,NT*NX,2,NY);
data1=reshape(data(:,1,:),NT,NX,NY);
intensity=permute(data1,[2 3 1]);
%变换坐标到NX*NY*NT,将z轴作为层
intensity=permute(intensity,[2 1 3]);
data2=reshape(data(:,2,:),NT,NX,NY);
phase=permute(data2,[2 3 1]);
phase=permute(phase,[2 1 3]);
%----------------------------4.Clear useless variables
--------------------------
clear header1 header2 header3 header4 header5 header6
header7 header8 header9 header10 header11 header12 NT NX NY phase
F_Start F_Stop F_Stop_meas NF ans count data data1 da