Hello everyone, I got this error and I do not know how to solve. I used guidata(hObject, handles); but it solves the half of the error. Could you help me finding the problem in the following code please?
조회 수: 3 (최근 30일)
이전 댓글 표시
Warning: Suspicious fragmentary file, might not be DICOM.
> In dicomread>newDicomread (line 202)
In dicomread (line 89)
In Hitung_Luas_GUI>pushbutton1_Callback (line 120)
In gui_mainfcn (line 95)
In Hitung_Luas_GUI (line 42)
In matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)Hitung_Luas_GUI('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Warning: Not enough data imported. Attempted to read 1179258880 bytes at position 8. Only read 59264.
> In dicomread>newDicomread (line 202)
In dicomread (line 89)
In Hitung_Luas_GUI>pushbutton1_Callback (line 120)
In gui_mainfcn (line 95)
In Hitung_Luas_GUI (line 42)
In matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)Hitung_Luas_GUI('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
function varargout = Hitung_Luas_GUI(varargin)
% HITUNG_LUAS_GUI MATLAB code for Hitung_Luas_GUI.fig
% HITUNG_LUAS_GUI, by itself, creates a new HITUNG_LUAS_GUI or raises the existing
% singleton*.
%
% H = HITUNG_LUAS_GUI returns the handle to a new HITUNG_LUAS_GUI or the handle to
% the existing singleton*.
%
% HITUNG_LUAS_GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in HITUNG_LUAS_GUI.M with the given input arguments.
%
% HITUNG_LUAS_GUI('Property','Value',...) creates a new HITUNG_LUAS_GUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Hitung_Luas_GUI_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Hitung_Luas_GUI_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help Hitung_Luas_GUI
% Last Modified by GUIDE v2.5 25-Dec-2019 00:30:57
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Hitung_Luas_GUI_OpeningFcn, ...
'gui_OutputFcn', @Hitung_Luas_GUI_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before Hitung_Luas_GUI is made visible.
function Hitung_Luas_GUI_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 Hitung_Luas_GUI (see VARARGIN)
% Choose default command line output for Hitung_Luas_GUI
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
movegui(hObject,'center');
% UIWAIT makes Hitung_Luas_GUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Hitung_Luas_GUI_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 togglebutton1.
function togglebutton1_Callback(hObject, eventdata, handles)
% hObject handle to togglebutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of togglebutton1
% --- Executes on button press in togglebutton2.
function togglebutton2_Callback(hObject, eventdata, handles)
% hObject handle to togglebutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of togglebutton2
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile('*.*');
if ~isequal(filename,0)
set(handles.pushbutton2,'Enable','on')
axes(handles.axes1)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])
axes(handles.axes2)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])
axes(handles.axes3)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])
Img = dicomread(fullfile(pathname, filename));
axes(handles.axes1)
imshow(Img,[])
title('Citra Asli')
set(handles.pushbutton2,'Enable','on')
set(handles.pushbutton3,'Enable','off')
else
return
end
handles.Img = Img;
guidata(hObject, handles)
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Img = handles.Img;
axes(handles.axes2)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])
axes(handles.axes3)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])
set(handles.pushbutton3,'Enable','off')
set(handles.edit1,'String',[])
set(handles.edit2,'String',[])
axes(handles.axes1)
cla reset
imshow(Img,[])
title('Citra Asli')
h = imrect;
setColor(h,'b')
mask = createMask(h);
% delete(h);
bw = activecontour(Img,mask,1000);
bw = imfill(bw,'holes');
bw = bwareaopen(bw,500);
bw = imclearborder(bw);
axes(handles.axes2)
cla reset
imshow(Img,[])
title('Hasil Segmentasi')
axis off
hold on
[c,~] = bwboundaries(bw,'noholes');
for k = 1:length(c)
boundary = c{k};
plot(boundary(:,2), boundary(:,1),'y','LineWidth',3)
end
hold off
axes(handles.axes3)
cla reset
imshow(bw)
title('Citra Biner')
set(handles.pushbutton3,'Enable','on')
handles.bw = bw;
guidata(hObject, handles)
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
bw = handles.bw;
s = regionprops(bw, 'area','perimeter');
area_bw = cat(1, s.Area);
perim_bw = cat(1, s.Perimeter);
res = 1.362; % resolusi spasial 1.362 pixel/mm
area = area_bw/(res^2)/100;
perimeter = perim_bw/res/10;
set(handles.edit1,'String',[num2str(area),' cm2'])
set(handles.edit2,'String',[num2str(perimeter),' cm'])
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes1)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])
axes(handles.axes2)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])
axes(handles.axes3)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])
set(handles.edit1,'String',[])
set(handles.edit2,'String',[])
set(handles.pushbutton2,'Enable','off')
set(handles.pushbutton3,'Enable','off')
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit 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
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit 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
댓글 수: 12
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!