GUI register?
古いコメントを表示
Hi,
I'm wandering how come the below code from GUI doesnt create registers that are stored in workplace? What should i do if i wana create the register in workplace via GUI?
function im1_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to im1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global a;
[FileName,PathName]= uigetfile(...
{'*.bmp;*.jpg;*.jpeg;*.tif;*.tiff;*.png','All Image Files(*.bmp,*.jpg,*.jpeg,*.tif,*.tiff,*.png)';...
'*bmp','bitmap Files (*.bmp)';...
'*.jpg;*.jpeg','JPEG Files(*.jpg,*.jpeg)';...
'*.tif;*.tiff','Tiff Files(*.tif,*.tiff)';...
'*png','PNG Files (*.png)';...
'*.*','All Files (*.*)'}, ...
'Pick an image file');
fullpath = sprintf('%s%s',PathName, FileName);
a=imread(fullpath);
imshow(fullpath,'parent',handles.im1);
4 件のコメント
Paulo Silva
2011 年 7 月 9 日
can you please explain what are you talking about? what is the register?
Image Analyst
2011 年 7 月 10 日
Maybe he means variable??? But he declared "a" global, so I'm not sure what he's talking about either. By the way, you already read in the image. So I'd do it this way instead:
axes(handles.im1);
imshow(a);
Kyle
2011 年 7 月 10 日
Image Analyst
2011 年 7 月 10 日
Yes, that is true. It is more like a "friend" or shared variable than a true global. It's not really global, only routines that have the line "global a;" will be able to see it. It's saved in the global workspace of your m-file so you won't see it in the "base" workspace which is always there, even when your code finishes. If you need it in the base workspace (for some reason that I can't figure out) then you need to call assignin, as the others said.
採用された回答
その他の回答 (1 件)
Paulo Silva
2011 年 7 月 10 日
Like Prabhakar said use assignin
a=imread(fullpath);
assignin('base','a',a);
カテゴリ
ヘルプ センター および File Exchange で File Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!