[問題]GUI讀檔已回收
小弟有個問題
就是我可以讓使用者一開始選擇要處理圖片所在的資料夾
可是為什麼我的listbox裡面讀不到東西,而且有錯誤
然後我關掉再開一遍
他跑出個視窗 上面寫說在XXX資料夾裡面找不到xxx.m
叫我要 add to path
可是我XXX的資料夾明明就有那個m檔案
可是我剛剛第一次就已經把dirctory設定在我m檔案的資料夾
那如果我點下去add to path 就可以了
可是這樣變成我要先跑程式一次,然後有錯誤,再關掉
再跑一次,他跑出一個視窗,我在點add to path 這樣才可以
不知道哪裡可以改的地方
以下是程式碼
function May_OpeningFcn(hObject, eventdata, handles, varargin)
filepath=uigetdir('','請選擇圖片所在資料夾')
cd(filepath);
handles.output = hObject;
guidata(hObject, handles);
a = dir('*.tif') %假設圖檔為tif檔
for i = 1:size(a) % 取得幾個圖檔
picname{i} = a(i).name; % 將圖檔的名字放入cell內
end
set(handles.listbox1,'String',picname) % 這裡將圖檔的名字設定到listbox內
X = get(handles.listbox1,'Value'); % 取得第幾個圖
pic = imread(a(X).name); % 讀圖
axes(handles.axes1) % 將圖鎖定在畫布上
imshow(pic); % 將圖鎖定在畫布上
guidata(hObject, handles);
function pushbutton1_Callback(hObject, eventdata, handles)
a = dir('*.tif') %假設圖檔為tif檔
for i = 1:size(a) % 取得幾個圖檔
picname{i} = a(i).name; % 將圖檔的名字放入cell內
end
X = get(handles.listbox1,'Value'); % 取得第幾個圖
pic = imread(a(X).name); % 讀圖
eh=histeq(pic);
axes(handles.axes2);
imshow(eh);
錯誤訊息
??? Undefined function or method 'May' for input arguments of type 'struct'.
Error in ==>
guidemfile>@(hObject,eventdata)May('listbox1_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.171.62.142
MATLAB 近期熱門文章
PTT數位生活區 即時熱門文章