📄 volumization.m
字号:
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
s=handles.s;
[m,n,p]=size(s);
step=1/m;
slider_step(1)=step;
slider_step(2)=step;
set(handles.slidery, 'SliderStep', slider_step, 'Max', m, 'Min',0)
iy=get(hObject,'Value');
iy=round(iy);
set(handles.yi,'string',iy);
set(handles.iy,'string',iy);
[x,y,z] = meshgrid([1:n],[1:m],[1:p]);
figure(1)
hy=slice(x,y,z, s,[],iy,[]);
alpha('color')
set(hy,'EdgeColor','none','FaceColor','interp', 'FaceAlpha','interp')
axis tight
alphamap('rampdown')
handles.IY=iy;
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function sliderz_CreateFcn(hObject, eventdata, handles)
% hObject handle to sliderz (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor',[.9 .9 .9]);
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on slider movement.
function sliderz_Callback(hObject, eventdata, handles)
% hObject handle to sliderz (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
s=handles.s;
[m,n,p]=size(s);
step=1/p;
slider_step(1)=step;
slider_step(2)=step;
set(handles.sliderz, 'SliderStep', slider_step, 'Max', p, 'Min',0)
iz=get(hObject,'Value');
iz=round(iz);
set(handles.zi,'string',iz);
set(handles.iz,'string',iz);
figure(1)
[x,y,z] = meshgrid([1:n],[1:m],[1:p]);
figure(1)
hz=slice(x,y,z, s,[],[],iz);
alpha('color')
set(hz,'EdgeColor','none','FaceColor','interp', 'FaceAlpha','interp')
axis tight
alphamap('rampdown')
handles.IZ=iz;
guidata(hObject, handles);
% --- Executes on button press in all_three.
function all_three_Callback(hObject, eventdata, handles)
% hObject handle to all_three (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
s=handles.s;
ix=handles.IX;
iy=handles.IY;
iz=handles.IZ;
[m,n,p]=size(s);
figure(1)
[x,y,z] = meshgrid([1:n],[1:m],[1:p]);
figure(1)
hz=slice(x,y,z, s,ix,iy,iz);
alpha('color')
set(hz,'EdgeColor','none','FaceColor','interp', 'FaceAlpha','interp')
axis tight
alphamap('rampdown')
aspect=handles.aspect;
daspect(aspect)
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function ix_CreateFcn(hObject, eventdata, handles)
% hObject handle to ix (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function ix_Callback(hObject, eventdata, handles)
% hObject handle to ix (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 ix as text
% str2double(get(hObject,'String')) returns contents of ix as a double
ix=str2double(get(hObject,'String')) ;
handles.IX=ix;
s=handles.s;
iy=handles.IY;
iz=handles.IZ;
[m,n,p]=size(s);
figure(1)
[x,y,z] = meshgrid([1:n],[1:m],[1:p]);
figure(1)
hz=slice(x,y,z, s,ix,iy,iz);
alpha('color')
set(hz,'EdgeColor','none','FaceColor','interp', 'FaceAlpha','interp')
axis tight
alphamap('rampdown')
aspect=handles.aspect;
daspect(aspect)
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function iy_CreateFcn(hObject, eventdata, handles)
% hObject handle to iy (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function iy_Callback(hObject, eventdata, handles)
% hObject handle to iy (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 iy as text
% str2double(get(hObject,'String')) returns contents of iy as a double
iy=str2double(get(hObject,'String')) ;
handles.IY=iy;
s=handles.s;
ix=handles.IX;
iz=handles.IZ;
[m,n,p]=size(s);
figure(1)
[x,y,z] = meshgrid([1:n],[1:m],[1:p]);
figure(1)
hz=slice(x,y,z, s,ix,iy,iz);
alpha('color')
set(hz,'EdgeColor','none','FaceColor','interp', 'FaceAlpha','interp')
axis tight
alphamap('rampdown')
aspect=handles.aspect;
daspect(aspect)
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function iz_CreateFcn(hObject, eventdata, handles)
% hObject handle to iz (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function iz_Callback(hObject, eventdata, handles)
% hObject handle to iz (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 iz as text
% str2double(get(hObject,'String')) returns contents of iz as a double
iz=str2double(get(hObject,'String')) ;
handles.IZ=iz;
s=handles.s;
ix=handles.IX;
iy=handles.IY;
[m,n,p]=size(s);
figure(1)
[x,y,z] = meshgrid([1:n],[1:m],[1:p]);
figure(1)
hz=slice(x,y,z, s,ix,iy,iz);
alpha('color')
set(hz,'EdgeColor','none','FaceColor','interp', 'FaceAlpha','interp')
axis tight
alphamap('rampdown')
aspect=handles.aspect;
daspect(aspect)
guidata(hObject, handles);
% --------------------------------------------------------------------
function smooth_Callback(hObject, eventdata, handles)
% hObject handle to smooth (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
figure(1)
clf
s=handles.s;
size=inputdlg('Enter the size of smoothing kernel','Smoothing filter');
size=str2double(size);
s_sm = smooth3(s, 'gaussian',[size size size]);
handles.s=s_sm;
guidata(hObject, handles);
% --- Executes on slider movement.
function isosurface_Callback(hObject, eventdata, handles)
% hObject handle to isosurface (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
s=handles.s;
aspect=handles.aspect;
Min=round(min(min(min(s))));
Max=round(max(max(max(s))));
v=[Min:1:Max];
K=Max-Min;
[m,n]=size(v);
step=1/n;
slider_step(1)=step;
slider_step(2)=step;
set(handles.isosurface, 'SliderStep', slider_step, 'Max', K, 'Min',0)
i=get(hObject,'Value');
i=round(i);
if i<=Min
i=Min;
elseif i>=Max
i=Max
else
end
i=i+Min;
handles.i=i;
set(handles.iso_value,'string',i);
[n,m,p]=size(s);
a=100*ones([n m p]);
s_inv=a-s;
figure(1)
clf
hiso=patch(isosurface(s,i),'FaceColor',[1,0.75,0.65], 'EdgeColor', 'none','FaceAlpha',0.7);
hcap=patch(isocaps(s_inv,(100-i)),'FaceColor',[1,0.75,0.65], 'Edgecolor','none','FaceAlpha',0.7);
view(45,30);
axis tight
daspect(aspect)
lightangle(45,30)
lighting phong
set(hcap,'AmbientStrength', 0.6)
set(hiso,'SpecularColorReflectance',0.3,'SpecularExponent', 50)
handles.count=0;
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function isosurface_CreateFcn(hObject, eventdata, handles)
% hObject handle to isosurface (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor',[.9 .9 .9]);
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes during object creation, after setting all properties.
function isosurf_multiple_CreateFcn(hObject, eventdata, handles)
% hObject handle to isosurf_multiple (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor',[.9 .9 .9]);
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on slider movement.
function isosurf_multiple_Callback(hObject, eventdata, handles)
% hObject handle to isosurf_multiple (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
count=handles.count;
s=handles.s;
value=handles.v;
aspect=handles.aspect;
Min=round(min(min(min(s))));
Max=round(max(max(max(s))));
v=[Min:1:Max];
K=Max-Min;
[m,n]=size(v);
step=1/n;
slider_step(1)=step;
slider_step(2)=step;
set(handles.isosurf_multiple, 'SliderStep', slider_step, 'Max', K, 'Min',0)
i=get(hObject,'Value');
i=round(i);
if i<=Min
i=Min;
elseif i>=Max
i=Max
else
i=i;
end
i=i+Min;
handles.i=i;
set(handles.iso_value_multi,'string',i);
[n,m,p]=size(s);
figure(1)
hold on
hiso=patch(isosurface(s,i),'FaceColor',[(0.85-count*0.1),(0.25+count*0.1),(0.35+count*0.1)], 'EdgeColor', 'none','FaceAlpha',0.7);
view(45,30);
axis tight
daspect(aspect)
set(hiso,'SpecularColorReflectance',0.3,'SpecularExponent', 50)
count=count+1;
handles.count=count;
value{count}=num2str(i);
outstring=textwrap(value,3);
set(handles.value,'string',outstring)
handles.v=value;
guidata(hObject, handles);
% --- Executes on button press in Clear.
function Clear_Callback(hObject, eventdata, handles)
% hObject handle to Clear (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
figure(1)
clf
handles.count=0;
handles.v={'0'};
set(handles.value,'string',{})
guidata(hObject, handles);
% --------------------------------------------------------------------
function about_Callback(hObject, eventdata, handles)
% hObject handle to about (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
msgbox('This a GUI for visualizing 3D data. Created by K.Artyushkova. kartyush@unm.edu. December 2004','About GUI Volumization')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -