function error while using sb2ind function

when i m using this:
isequal(~rem(CentroidTerm,1),bsxfun(@ge,CentroidTerm ,[1 1]),bsxfun(@le,CentroidTerm ,[m n]))
the output is :
ans 1 ans 1 ans 1 ans 0 three are 1 and one is 0 . what does that mean. plz tell me

1 comentario

Sean de Wolski
Sean de Wolski el 19 de Jul. de 2011
bsxfun(@ge,CentroidTerm ,[1 1])
could just be:
CentroidTerm>=1;
no need for the singleton expansion since you're comparing to a scalar value.

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 19 de Jul. de 2011

0 votos

It means that one of the subscripts you are trying to use is out of range; in particular it appears that one of your CentroidTerm(:,2) is greater than n.

2 comentarios

deepak deepak
deepak deepak el 20 de Jul. de 2011
i just checked the code again but i couldnt find the errror.can u help me actually i m doing my M.Tech. project on fingerprints.
this is the code for distance computation:
h = waitbar(0,'Distance Computation');
switch nargin
case 1
[m1,n1]=size(dataset1);
m2=m1;
D=zeros(m1,m2);
for i=1:m1
waitbar(i/m1)
for j=1:m2
if i==j
D(i,j)=NaN;
else
D(i,j)=sqrt((dataset1(i,1)-dataset1(j,1))^2+(dataset1(i,2)-dataset1(j,2))^2);
end
end
end
case 2
[m1,n1]=size(dataset1);
[m2,n2]=size(dataset2);
D=zeros(m1,m2);
for i=1:m1
waitbar(i/m1)
for j=1:m2
D(i,j)=sqrt((dataset1(i,1)-dataset2(j,1))^2+(dataset1(i,2)-dataset2(j,2))^2);
end
end
otherwise
error('only one or two input arguments')
end
close(h)
this function is called by this:
%% Termination
LTerm=(L==1);
imshow(LTerm)
LTermLab=bwlabel(LTerm);
propTerm=regionprops(LTermLab,'Centroid');
CentroidTerm=round(cat(1,propTerm(:).Centroid));
imshow(~K)
set(gcf,'position',[1 1 600 600]);
hold on
plot(CentroidTerm(:,1),CentroidTerm(:,2),'ro')
%% Bifurcation
LBif=(L==3);
LBifLab=bwlabel(LBif);
propBif=regionprops(LBifLab,'Centroid','Image');
CentroidBif=round(cat(1,propBif(:).Centroid));
plot(CentroidBif(:,1),CentroidBif(:,2),'go')
D=6;
%% Process 1
Distance=DistEuclidian(CentroidBif,CentroidTerm);
SpuriousMinutae=Distance<D;
[i,j]=find(SpuriousMinutae);
CentroidBif(i,:)=[];
CentroidTerm(j,:)=[];
%% Process 2
Distance=DistEuclidian(CentroidBif);
SpuriousMinutae=Distance<D;
[i,j]=find(SpuriousMinutae);
CentroidBif(i,:)=[];
%% Process 3
Distance=DistEuclidian(CentroidTerm);
SpuriousMinutae=Distance<D;
[i,j]=find(SpuriousMinutae);
CentroidTerm(i,:)=[];
%% Suppress extrema minutiae
% Once we defined the ROI, we can suppress minutiae external to this ROI.
[m,n]=size(I(:,:,1));
isequal(~rem(CentroidTerm,1),bsxfun(@ge,CentroidTerm ,[1 1]),bsxfun(@le,CentroidTerm ,[m n]))
indTerm=sub2ind([m,n],CentroidTerm(:,1),CentroidTerm(:,2));
Z=zeros(m,n);
Z(indTerm)=1;
ZTerm=Z.*ROI';
[CentroidTermX,CentroidTermY]=find(ZTerm);
X1=CentroidTermX;
Y1=CentroidTermY;
Z1=[X1,Y1];
[a,b]=size(Z1);
Z1(a+1:200,:)=0;
indBif=sub2ind([m,n],CentroidBif(:,1),CentroidBif(:,2));
Z=zeros(m,n);
Z(indBif)=1;
ZBif=Z.*ROI';
[CentroidBifX,CentroidBifY]=find(ZBif);
U1=CentroidBifX;
V1=CentroidBifY;
W1=[U1,V1];
[a,b]=size(W1);
W1(a+1:200,:)=0;
A=cat(2,Z1,W1);
imshow(I)
hold on
plot(CentroidTermX,CentroidTermY,'ro','linewidth',2)
plot(CentroidBifX,CentroidBifY,'go','linewidth',2)
if u can find out where is the error plz tell me.
Sean de Wolski
Sean de Wolski el 20 de Jul. de 2011
Did you write this code yourself?

Iniciar sesión para comentar.

Etiquetas

Preguntada:

el 19 de Jul. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by