Problem about DICOM Image GUI

조회 수: 1 (최근 30일)
KHOR  WEI KOK
KHOR WEI KOK 2016년 3월 26일
편집: Walter Roberson 2016년 4월 2일
how can i insert list of dicom images into listbox and display in one of axes?? I have a folder containg dicom images and i want to insert list of images into the listbox. Any example for GUI DICOM images?

채택된 답변

Walter Roberson
Walter Roberson 2016년 3월 27일
dinfo = dir('*.dcm');
dcm_files = {dinfo.name};
set( handles.listbox1, 'String', dcm_files);
...
function listbox1_Callback(src, event, handles)
box_choices = get(src, 'String');
box_chosen = get(src, 'Value');
file_chosen = box_choices{box_chosen};
[ImageData, ImageMap] = imread(file_chosen);
imshow( ImageData, ImageMap, 'Parent', handles.axes_to_display_in);
axis(handles.axes_to_display_in, 'image');
  댓글 수: 3
Walter Roberson
Walter Roberson 2016년 3월 27일
That is a proper example. Just change "listbox1" to the Tag you used for your listbox, and change "axes_to_display_in" to the tag you used for the axes to display the image in.
KHOR  WEI KOK
KHOR WEI KOK 2016년 4월 2일
편집: Walter Roberson 2016년 4월 2일
% --- Executes just before fyp2016 is made visible.
function fyp2016_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to fyp2016 (see VARARGIN)
% Choose default command line output for fyp2016
% Choose default command line output for DICOMFiles
handles.output = hObject;
handles.cdir = pwd;
set(handles.DicomListBox,'enable','off');
guidata(hObject, handles);
% UIWAIT makes fyp2016 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = fyp2016_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in InsertPushButton.
function InsertPushButton_Callback(hObject, eventdata, handles)
% hObject handle to InsertPushButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.output = hObject;
fn = uigetdir(handles.cdir,'Select directory');
if fn ~= 0
handles.cdir = fn;
img = dir(fullfile(handles.cdir,'*.dcm'));
for x = 1 : length(img)
handles.I{x} = dicomread(fullfile(handles.cdir,img(x).name));
end
if length(img) ~= 0, set(handles.DicomListBox,'enable','on');
else
set(handles.DicomListBox,'enable','off');
end
set(handles.NofFiles,'string',handles.cdir);
set(handles.DicomListBox,'string',{img.name});
end
guidata(hObject, handles);
% --- Executes on selection change in DicomListBox.
function DicomListBox_Callback(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns listbox1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox1
handles.output = hObject;
index = get(handles.DicomListBox,'value');
axes(handles.OutputDicom);
imshow(handles.I{index});
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function DicomListBox_CreateFcn(hObject, eventdata, handles)
% hObject handle to DicomListBox (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
return
I dont know why my axes(OutputDicom) showed only black image. Can you help me check what is the problem?

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 DICOM Format에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by