Why my code keep running non stop?

Hi. I wanna know why my code keep running non stop? There's no error displayed.
image1= getimage(handles.axes1)
bw1=imresize(image1,[128 128])
bw1=rgb2gray(bw1)
%binarization
bw1=im2double(bw1);
bw1 = im2bw(bw1,0.90);
%thinning
BW3=bwmorph(~bw1,'thin',0.9)
%Extracting black pixel
k=1
for i=1:128
for j=1:128
if(BW3(i,j)==0)
u(k)=i
v(k)=j
k=k+1
BW3(i,j)=1
end
end
end
C=[u;v] %the curve of signature
N=k-1 %no of pixel in signature
oub=sum(C(1,:))/N %x coordinate cnter of mass
ovb=sum(C(2,:))/N %y coordinate cnter of mass
%rotate
for i=1:N
u(i)=u(i)-oub+1
v(i)=v(i)-ovb+1
end
%the new curve of signature
C=[u;v]
ub=sum(C(1,:))/N
vb=sum(C(2,:))/N
ubSq=sum((C(1,:)-ub).^2)/N
vbSq=sum((C(2,:)-vb).^2)/N
for i=1:N
uv(i)=u(i)*v(i)
end
uvb=sum(uv)/N
M=[ubSq uvb;uvb vbSq]
minIgen=min(abs(eig(M)))
MI=[ubSq-minIgen uvb;uvb vbSq-minIgen]
theta=(atan((-MI(1))/MI(2))*180)/pi
thetaRad=(theta*pi)/180
rotMat=[cos(thetaRad)-sin(thetaRad);sin(thetaRad)
cos(thetaRad)];
%rotate the signature passing the new coordinate
for i=1;N
v(i)=(C(2,i)*cos(thetaRad))-(C(1,i)*sin(thetaRad))
u(i)=(C(2,i)*sin(thetaRad))+(C(1,i)*cos(thetaRad))
end
C=[u;v]
for i=1;N
u(i)=round(u(i)+oub-1)
v(i)=round(v(i)+ovb-1)
end
mx=0
my=0
if(min(u)<0)
mx=-min(u)
for i=1:N
u(i)=u(i)+mx+1
end
end
if(min(v)<0)
my=-min(v)
for i=1:N
v(i)=v(i)+my+1
end
end
C=[u;v]
for i=1:N
BW3((u(i)),(v(i)))=0
end
xstart=128
xend=1
ystart=128
yend=1
for r=1:128
for c=1:128
if((BW3(r,c)==0))
if(r<ystart)
ystart=r
end
if((r>yend))
yend=r
end
if(c<xstart)
xstart=c
end
if(c>xend)
xend=c
end
end
end
end
for i=ystart:yend
for j=xstart:xend
im((i-ystart+1),(j-xstart+1))=BW3(i,j)
end
end
%display result at axes2
axes(handles.axes2)
imshow(im)

4 comentarios

Walter Roberson
Walter Roberson el 14 de Oct. de 2019
Your code ends when I run it.
I recommend that you learn to put a semi-colon on the end of lines that assign into arrays in a loop, as otherwise you display a lot of information to the screen that likely does not need to be displayed at least until the loop finishes.
Najwa Samlan
Najwa Samlan el 14 de Oct. de 2019
Okay I already put the semicolon but then an error occur:-
Subscript indices must either be real positive integers or logicals.
Error in tetst>pushbutton2_Callback (line 145)
BW3((u(i)),(v(i)))=0;
May I know why this error occur?
for i=1;N
should be
for i=1:N
Image Analyst
Image Analyst el 14 de Oct. de 2019
Chances are, u(i) or v(i) is zero. See the FAQ.

Iniciar sesión para comentar.

Respuestas (0)

Preguntada:

el 14 de Oct. de 2019

Comentada:

el 14 de Oct. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by