how can i browse an image in gui

조회 수: 14 (최근 30일)
Usama Javed
Usama Javed 2012년 1월 5일
댓글: Image Analyst 2016년 11월 20일
how can i browse an dicom image in matlab gui???

채택된 답변

Chandra Kurniawan
Chandra Kurniawan 2012년 1월 9일
Hi, Usama
Here I give you sample code with GUIDE.
First, you need to create your GUI.
Type 'guide' in command window, and select 'blank GUI'
Then design your GUI. Your GUI must contains Axes, Pushbutton, and Edit as shown in the picture bellow
And type this code at 'pushbutton1_Callback'
function pushbutton1_Callback(hObject, eventdata, handles)
handles.output = hObject;
[fn pn] = uigetfile('*.dcm','select dicom file');
complete = strcat(pn,fn);
set(handles.edit1,'string',complete);
I = dicomread(complete);
imshow(I,[]);
guidata(hObject, handles);
I hope this clear.
  댓글 수: 13
Michal Urban
Michal Urban 2016년 11월 20일
Hi, i have one problem, when i use this code , still not working , can u someone help me? I have 4 files dicom data and i need code for showing this data.
Image Analyst
Image Analyst 2016년 11월 20일
Michal, post your code and image in a new thread.

댓글을 달려면 로그인하십시오.

추가 답변 (7개)

Junaid
Junaid 2012년 1월 5일
Dear Usman,
If I understand you correct. You mean how to browse image from GUI right?
If yes then it is as follow:
a=imgetfile;
where a is your image.
  댓글 수: 1
Usama Javed
Usama Javed 2012년 1월 5일
actually i m trying to read an image from browse control.. i-e
there will be an edit text control and a push button(browse Button).. the path will set in that edit text box so that i can read an image at that path

댓글을 달려면 로그인하십시오.


Chandra Kurniawan
Chandra Kurniawan 2012년 1월 5일
[fn pn] = uigetfile('*.dcm','select dicom file');
complete = strcat(pn,fn);
set(handles.edit1,'string',complete);
I = dicomread(complete);
  댓글 수: 2
Usama Javed
Usama Javed 2012년 1월 8일
??? Undefined function or variable 'handles'.
Error in ==> Untitled at 3
set(handles.edit1,'string',complete);
Chandra Kurniawan
Chandra Kurniawan 2012년 1월 9일
Hi,
Here, I Just give you little hint.
Of course you cannot apply my code directly to your script.
You need to do your own modification.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2012년 1월 5일
Try MAGIC:
Description
This GUI will help the novice user get up to speed very quickly on using GUI-based applications. Everything is laid out in a very simple Step 1, Step 2, Step 3, etc. layout. It is a very good starting point for a typical image analysis application. This application uses GUIDE to do the user interface design, and has most of the basic controls such as buttons, listboxes, checkboxes, radio buttons, scrollbars, etc. It allows the user to select a folder of images, select one or more images and display them, to select a series of options, and to individually or batch process one or more images. The user can optionally apply a mask (region of interest) to the image so that only the area within the mask will be analyzed. The results are optionally sent to Excel. In this demo, I do some very basic particle sizing but in use, the user would replace that simple demo code in the function AnalyzeSingleImage() with their own code. Works with Windows or Unix since paths are all forward slashes. Requires the Image Processing Toolbox to do the simple particle sizing demo, but if you delete that demo code before using it, then the IP toolbox would not be required and it would still demonstrate the basic GUI-based file processing functionality.

Seema
Seema 2012년 3월 24일
Hi Chandra, I executed the above code & it's working for me. But could u plz tell me which line in ur code enables the image selected to be displayed in the axes. Actually I'm not able to understand the meaning of the line "handles.output = hObject; [fn pn] = uigetfile('*.dcm','select dicom file'); "
Regards, Seema
  댓글 수: 1
Image Analyst
Image Analyst 2012년 3월 25일
The "getfile()" line gets the filename (a string). imread() reads in the image from disk into a variable in your program. The "imshow()" line is the line that does the actual displaying of the image.

댓글을 달려면 로그인하십시오.


msp
msp 2013년 4월 12일
how to get path of uigetfile?
  댓글 수: 1
Image Analyst
Image Analyst 2013년 4월 12일
You posted this as an answer to Usama's question, but it's obviously not an answer to his question. So, if it's supposed to be a comment or followup question on one of the actual answers, whose answer are you commenting on? If you intended this to be a brand new discussion question of your own, then please post it as a new question, not as an answer.

댓글을 달려면 로그인하십시오.


Muthukumar Thangam
Muthukumar Thangam 2013년 9월 7일
% Try this for browse and load jpg images
% code
function pushbutton1_Callback(hObject, eventdata, handles)
handles.output = hObject;
[fn pn] = uigetfile('*.jpg','select jpg file');
complete = strcat(pn,fn);
set(handles.edit1,'string',complete);
I = imread(complete);
imshow(I,[]);
guidata(hObject, handles);
  댓글 수: 4
kiran
kiran 2014년 4월 4일
i think you have misunderstood my question.
if true
% code
function pushbutton1_Callback(hObject, eventdata, handles)
handles.output = hObject;
[fn pn] = uigetfile('*.jpg','select jpg file');
complete = strcat(pn,fn);
set(handles.edit1,'string',complete);
I = imread(complete);
imshow(I,[]);
guidata(hObject, handles);
end
this is the code i used to browse the image when i click the pushbutton on the gui. now when i click the browse button i need to select an image from the drive, i need to display the image and i need to save the image to a variable so that i will be able to use it when i click the convert button.
Image Analyst
Image Analyst 2014년 4월 4일
I did answer the original questions about how to display (use imshow) and how to put the image into a variable (use imread). For your new question about how to access the image when you click a different push button, see the FAQ http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F

댓글을 달려면 로그인하십시오.


Thirunavukkarasu
Thirunavukkarasu 2015년 2월 6일
What must be the size of the axes to load the .jpg image? how can we relate the size of the image with the size of the axes ?
  댓글 수: 1
Image Analyst
Image Analyst 2015년 2월 6일
They're independent. Your image will scale to fit whatever size your axes is.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by