Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
what happened to that cade?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Code i want the folder's images display on runtime and on that images i do image localization i run following code but facing error...
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= str2double(get(handles.edit2,'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
% % MyCode
myFolder='C:\Users\Romesha\Desktop\2';
if ~isdir(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
uiwait(warndlg(errorMessage));
return;
end
filePattern = fullfile(myFolder, '*.bmp');
jpegFiles = dir(filePattern);
for i1 = 1:pics
baseFileName = jpegFiles(i1).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
imageArray = imread(fullFileName);
imshow(imageArray); % Display image.
drawnow ; % Force display to update immediately.
imageArray = cell(1, pics); %% array for pics
%%reading images from GUI
% imgs{1} = imread('C:\Users\Romesha\Desktop\1\001_1_2.bmp');%%---------------%%
% imgs{2} = imread('C:\Users\Romesha\Desktop\2\001_2_1.bmp'); %%--------------%%
% imgs{3} = imread('C:\Users\Romesha\Desktop\2\001_2_2.bmp');
% imgs{4} = imread('C:\Users\Romesha\Desktop\2\001_2_3.bmp');
% imgs{5} = imread('C:\Users\Romesha\Desktop\2\001_2_4.bmp');
% imgs{6} = imread('C:\Users\Romesha\Desktop\1\001_1_1.bmp');
% imgs{7} = imread('C:\Users\Romesha\Desktop\1\001_1_3.bmp');
% imgs{8} = imread('C:\Users\Romesha\Desktop\3\002_1_1.bmp');
% imgs{9} = imread('C:\Users\Romesha\Desktop\3\002_1_2.bmp');
%for i1=1:pics
im = imageArray{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 i1(:,:,1)=im; i1(:,:,2)=im; i1(:,:,3)=im; else i1=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(i1,1) for j=1:size(i1,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) = i1(i,j,1);
nim(i,j,2) = i1(i,j,2);
nim(i,j,3) = i1(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(i1,1) for j=1:size(i1,2) if(I2(i,j)==1) ni(i,j,1) = i1(i,j,1); ni(i,j,2) = i1(i,j,2); ni(i,j,3) = i1(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
% --- 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 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
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 Error
Now reading C:\Users\Romesha\Desktop\2\001_2_1.bmp Assignment has more non-singleton rhs dimensions than non-singleton subscripts
Error in gui3>pb1_Callback (line 136) i1(:,:,1)=im;
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
1 commentaire
Réponses (1)
Walter Roberson
le 24 Jan 2014
You are trying to write into a variable named "i1". That is the same name as the existing "i1" which is the loop control variable for the "for" loop that you are in. You need to rename one of the two variables.
0 commentaires
Cette question est clôturée.
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!