what happened to the folowing code?

1 回表示 (過去 30 日間)
romasha
romasha 2014 年 1 月 23 日
回答済み: Amit 2014 年 1 月 23 日
  • Code: *function pb1_Callback(hObject, eventdata, handles)% hObject handle to pb1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)
alpha= str2num(get(handles.edit1,'String'));
pics=alpha; %no of pictures to be processed given by user
titl=0; %%helping to show title once
subplt=1; %%showing no of figures
imgs = cell(1, pics); %% array for pics
imgs{1} = imread('C:\Users\Romesha\Desktop\eye2.jpg'); %% reading images from GUI imgs{2} = imread('C:\Users\Romesha\Desktop\001_1_2.bmp'); %%---------------%% imgs{3} = imread('gray.jpg'); %%--------------%%
for i1=1:pics
im = imgs{i1};
subplot(pics,4,subplt); %% subplot(no_of_columns %%,no_of_row,numbering_0f_pic_in_column) imshow(im);
if titl==0 title('real Image'); end
subplt=subplt+1;
[r c wid] = size(im);
if wid==1 k(:,:,1)=im; k(:,:,2)=im; k(:,:,3)=im; else k=im; end
pt = ginput(2);
x1 = pt(1,1); y1 = pt(1,2); x2 = pt(2,1); y2 = pt(2,2); x = [x1 x2]; y = [y1 y2];
r = sqrt((x2-x1)^2 + (y2-y1)^2);
for i=1:size(k,1) for j=1:size(k,2) x2 = j; y2 = i; val = floor(sqrt((x2-x1)^2 + (y2-y1)^2)); if(val == floor(r)) nim(i,j,1) = 255; nim(i,j,2) = 0; nim(i,j,3) = 0; BW(i,j) = 1;
else
nim(i,j,1) = k(i,j,1);
nim(i,j,2) = k(i,j,2);
nim(i,j,3) = k(i,j,3);
BW(i,j) = 0;
end
end
end
SE = strel('disk',1); BW3 = imdilate(BW,SE);
I2 = imfill(BW3,'holes');
for i=1:size(k,1) for j=1:size(k,2) if(I2(i,j)==1) ni(i,j,1) = k(i,j,1); ni(i,j,2) = k(i,j,2); ni(i,j,3) = k(i,j,3); else ni(i,j,1) = 0; ni(i,j,2) = 0; ni(i,j,3) = 0; end end end
ni = uint8(ni);
X1 = x1-r; X2 = x1+r;
Y1 = y1-r; Y2 = y1+r;
ROI = imcrop(ni,[X1,Y1,abs(X2-X1),abs(Y2-Y1)]); if wid==1 ROI = ROI(:,:,1); end
subplot(pics,4,subplt); imshow(ROI);
if titl==0 title('Croped pic'); end subplt=subplt+1;
%% histogram Equalization
% J = histeq(ROI); % % subplot(pics,4,subplt); % imshow(J); % if titl==0 % title('histogram equalization'); % end % subplt=subplt+1;
%% thresholding level = graythresh(ROI); e= im2bw(ROI,0.5);
% level = graythresh(J); % e= im2bw(level,0.5); % subplot(pics,4,subplt); imshow(e);
if titl==0 title('threshold'); end subplt=subplt+1; %% invertinng image (taking complement of image) IM2 = imcomplement(e);
subplot(pics,4,subplt); imshow(IM2);
if titl==0 title('inverted image'); end subplt=subplt+1; %% locating Circle Using Hough Transfrom Rmin = 30; Rmax = 200;
[centersBright, radiiBright] = imfindcircles(IM2,[Rmin Rmax],'Sensitivity',0.9);
[centersDark, radiiDark] = imfindcircles(IM2,[Rmin Rmax],'ObjectPolarity','dark');
t=viscircles(centersBright, radiiBright,'EdgeColor','b') C2=viscircles(centersDark, radiiDark,'LineStyle','--') %% Normalization % % c=ezpolar('1+cos(t)'); % imshow(c);
titl=titl+1; end
Error
Error using str2num (line 33) Requires string or character array input.
Error in gui3>pb1_Callback (line 82) alpha= str2num(get(handles.edit1,'String'));
Error in gui_mainfcn (line 96) feval(varargin{:});
Error in gui3 (line 42) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)gui3('pb1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback

採用された回答

Amit
Amit 2014 年 1 月 23 日
That means that handles.edit1 is not defined!!

その他の回答 (0 件)

製品

Community Treasure Hunt

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

Start Hunting!

Translated by