Problem about DICOM Image GUI

3 次查看(过去 30 天)
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