Problem about DICOM Image GUI

3 vues (au cours des 30 derniers jours)
KHOR  WEI KOK
KHOR WEI KOK le 26 Mar 2016
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?

Réponse acceptée

Walter Roberson
Walter Roberson le 27 Mar 2016
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 commentaires
Walter Roberson
Walter Roberson le 27 Mar 2016
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 le 2 Avr 2016
Modifié(e) : Walter Roberson le 2 Avr 2016
% --- 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?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur DICOM Format dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by