Effacer les filtres
Effacer les filtres

Why my code keep running non stop?

2 vues (au cours des 30 derniers jours)
Najwa Samlan
Najwa Samlan le 14 Oct 2019
Commenté : Image Analyst le 14 Oct 2019
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 commentaires
Walter Roberson
Walter Roberson le 14 Oct 2019
for i=1;N
should be
for i=1:N
Image Analyst
Image Analyst le 14 Oct 2019
Chances are, u(i) or v(i) is zero. See the FAQ.

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by