1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
function test
hfig = figure('units','normalized',...
'position',[0 0 1 1],...
'color',[0.8 0.8 0.8],...
'numbertitle','off',...
'name','Interface Matlab',...
'menubar','none',...
'tag','interface');
handles.ax1 = axes('units','normalized',...
'position',[0.1 0.1 0.6 0.8],...
'color',[1 1 1],...
'tag','image');
handles.bt1 = uicontrol('style','pushbutton',...
'units','normalized',...
'position',[0.8 0.5 0.08 0.08],...
'string','Load File',...
'callback', @LoadFile, ...
'tag','LoadFile');
handles.bt2 = uicontrol('style','pushbutton',...
'units','normalized',...
'position',[0.85 0.4 0.08 0.08],...
'string','Next Image',...
'callback',@NextImage,...
'tag','NextImage');
handles.bt3 = uicontrol('style','pushbutton',...
'units','normalized',...
'position',[0.75 0.4 0.075 0.075],...
'string','Prev Image',...
'callback',@PrevImage,...
'tag','PrevImage');
handles = guihandles(hfig);
guidata(hfig, handles);
%% Function ReadImage
function ReadImage(hfig, handles, fullpathname)
handles = guihandles(hfig);
fullpathname = get(handles.fullpathname,'String');
I = imread(fullpathname);
I = im2double(I);
imshow(I,'Parent', handles.ax1);
set(handles.I, 'String', mat2str(I));
guidata(hfig, handles);
end
%% Function LoadFile
function LoadFile(hfig, handles)
handles = guihandles(hfig);
[filename,pathname] = uigetfile({'*.*'},'Select Images');
if isequal(filename,0)
disp('Image not acquired');
else
disp('Image acquired');
end
filelist = dir(pathname);
namelist={};
cnum = 1;
for i=3:size(filelist,1)
namelist{cnum,1}=filelist(i,1).name;
cnum=cnum+1;
end
cnum = 1;
filename = namelist{cnum,1};
fullpathname = strcat(pathname, filename);
[tnum,x] = size(namelist);
set(handles.fullpathname, 'String', fullpathname);
set(handles.cnum, 'String', num2str(cnum));
set(handles.tnum, 'String', num2str(tnum));
guidata(hfig, handles);
ReadImage
end
%% Function NextImage
function NextImage(hfig, eventdata, handles)
handles = guihandles(hfig);
cnum = get(handles.cnum, 'String');
cnum = str2num(cnum);
tnum = get(handles.tnum, 'String');
tnum = str2num(tnum);
if cnum < tnum
cnum = cnum + 1;
set(handles.cnum, 'String', num2str(cnum));
guidata(hfig, handles);
ReadImage;
else
disp('Last Image');
end
end
%% Function PrevImage
function PrevImage(hfig, eventdata, handles)
handles = guihandles(hfig);
cnum = get(handles.cnum, 'String');
cnum = str2num(cnum);
if cnum > 1
cnum = cnum - 1;
set(handles.cnum, 'String', num2str(cnum));
ReadImage;
else
disp('First Image');
end
end
end |