我无法理解如何运行它,任何人都可以帮助我。
我收到此错误:
K>> [minutiae_valid]=postprocess_TICO(B,im,~K)
??? Attempted to access wind(273,386); index out of bounds because size(wind)=[368,385].
Error in ==> postprocess_TICO at 214
if (thinned(p,q)==1)&&(wind(p,q)==0)
postprocess_Tico
function [minutiae_valid]=postprocess_TICO(minutiae_valid,im1,thinned)
% clc;
% close all;
% clear all;
cell=16;%total no. of cells needed in quantization;
% im1= imread('E:\FINGERPRINT DATABASE\FVC2002\Dbs\Db1_a\16_6.tif');
wl=(33-1)/2;
% no=20;
% no2=20;
% nox = 0;
% noy = 0; %to choose border area
%
m=size(im1,1);
n=size(im1,2);
%m=(round(m/cell))*cell;
%n=(round(n/cell))*cell;
% im1=imresize(im1,[m n]);
% im=double(im1);
% figure;
% subplot(1,2,1);
% imshow(uint8(im));
% title('original input image');
%
% %Identify ridge-like regions and normalise image--------------------------
% blksze = 10;
% thresh =30;
% M0=100;
% STD0=150;
% [thinim, mask] = imgenhance(im, blksze, M0, STD0);
% subplot(1,2,2); subimage((thinim));
% title('Improved thinned input image', 'FontSize', 12);
% INPUT_IMG=thinim;
%
% %minutiae extraction
% thinned= INPUT_IMG;
% img = INPUT_IMG;
% [minutiae, minutiae_img, combined] = findminutiae(thinned, img);
% totminu_I = size(minutiae,1)
% figure,
% subplot(1,2,1), subimage(combined), title('minutiae before postprocess.')
% %______________________________________________________________
% %TO FIND BOUNDARY OF INPUT IMAGE AS WELL AS REGION OF FALSE MINU
% mask_input=mask;
% border=uint8(zeros(m,n));
%
% [m,n]=size(mask);
% validr=uint8(zeros(m,n));
% thin_temp=thinned;
% for i=1:m
% for j=2:n-1
% if((mask_input(i,j-1)==0)&&(mask_input(i,j)==1)&&(j<=n-no))
% border(i,j)=1;
% validr(i,j-nox:j+no)=1;
% thin_temp(i,j-nox:j+no)=1;
% end
%
% if ((mask_input(i,j+1)==0)&&(mask_input(i,j)==1)&&(j>no))
% border(i,j)=1;
% validr(i,j+nox:-1:j-no)=1;
% thin_temp(i,j+nox:-1:j-no)=1;
% end
%
% end
% end
%
% for i=1:m
% for j=1:n-1:n
% if (mask_input(i,j)==1)
% if (j==1)
% border(i,j)=1;
% validr(i,j:j+no)=1;
% thin_temp(i,j:j+no)=1;
% end
% if (j==n)
% border(i,j)=1;
% validr(i,j:-1:j-no)=1;
% thin_temp(i,j:-1:j-no)=1;
% end
% end
% end
% end
%
%
%
% for j=1:n
% for i=2:m-1
% if((mask_input(i-1,j)==0)&&(mask_input(i,j)==1)&&(i<=m-no))
% border(i,j)=1;
% validr(i-noy:i+no,j)=1;
% thin_temp(i-noy:i+no,j)=1;
% end
% if((mask_input(i+1,j)==0)&&(mask_input(i,j)==1)&&(i>no))
% border(i,j)=1;
% validr(i+noy:-1:i-no,j)=1;
% thin_temp(i+noy:-1:i-no,j)=1;
% end
%
% end
% end
%
% for j=1:n
% for i=1:m-1:m
% if (mask_input(i,j)==1)
% if (i==1)
% border(i,j)=1;
% validr(i:i+no,j)=1;
% thin_temp(i:i+no,j)=1;
% else validr(i:-1:i-no,j)=1;
% thin_temp(i:-1:i-no,j)=1;
% end
% end
% end
% end
%
% %___________________________________________________________________
% % removing minu at the border of roi
% for x=1:size(thinned,1)
% for y=1:size(thinned,2)
% if ((validr(x,y)==1)&&(thinned(x,y)==1))
% combined(x,y,:)=[255,255,255];
% minutiae_img(x,y,:)=[0,0,0];
%
% end
% end
% end
%
% for i=1:totminu_I
% x=minutiae(i,1);
% y=minutiae(i,2);
% if ((validr(x,y)==1)&&(thinned(x,y)==1))
% minutiae(i,:)=0;
% end
% end
% %__________________________
%
% subplot(1,2,2), subimage(combined), title('after boundary effect ')
% minu_count=1;
% minutiae_valid(minu_count, :) = [0,0,0,0]; %to make x, y, CN, theta value of minutiae not in border region.
% for i=1:totminu_I
% CN=minutiae(i,3);
% if (CN~=0)
% minutiae_valid(minu_count, :) = minutiae(i,:);
% minu_count = minu_count + 1;
% end
% end
% totminu_I= minu_count-1;
k=size(minutiae_valid);
totminu_I=k(1,1);
%FALSE RIDGE BIFURCATION
for i=1:totminu_I
if minutiae_valid(i,3)==3
wind=ones(m,n);
xi= minutiae_valid(i,1);
yi=minutiae_valid(i,2);
x=xi;
y=yi;
wind(xi-wl:xi+wl,yi-wl:yi+wl)=0; %window of size 25 cross 25
wind(xi,yi)=-1;
%mark '1', '2', '3'.
value=0;
r=x-1;
for c=y-1:y+1
if (thinned(r,c)==1)&&(wind(r,c)==0)
value=value+1;
wind(r,c)=value;
end
end
c=y+1;
for r=x-1:x+1
if (thinned(r,c)==1)&&(wind(r,c)==0)
value=value+1;
wind(r,c)=value;
end
end
r=x+1;
for c=y+1:-1:y-1
if (thinned(r,c)==1)&&(wind(r,c)==0)
value=value+1;
wind(r,c)=value;
end
end
c=y-1;
for r=x+1:-1:x-1
if (thinned(r,c)==1)&&(wind(r,c)==0)
value=value+1;
wind(r,c)=value;
end
end
for value=1:3 %search '1'/'2/'3' value pixel arond the minutia point in the window.
for p=x-1:x+1
for q=y-1:y+1
if wind(p,q)==value
xi=p;
yi=q;
end
end
end
cnt=0;
while(xi>x-wl)&&(xi<x+wl)&&(yi>y-wl)&&(yi<y+wl) %mark '1'/'2'/'3' to the adjacent connected pixels
k=0;
for p=xi-1:xi+1
for q=yi-1:yi+1
if (thinned(p,q)==1)&&(wind(p,q)==0)
wind(p,q)=value;
k=k+1;
if k==1
x1=p;
y1=q;
end
if k==2 %more than one connected pixel
cnt=cnt+1;
x2=p;
y2=q;
t1=x1;
x1=x2;
x2=t1;
t2=y1;
y1=y2;
y2=t2;
%___________
xi=x2;
yi=y2;
while(xi>x-wl)&&(xi<x+wl)&&(yi>y-wl)&&(yi<y+wl)
k=0;
flag_see=0;
for p=xi-1:xi+1
for q=yi-1:yi+1
if (thinned(p,q)==1)&&(wind(p,q)==0)
wind(p,q)=value;
flag_see=1;
x3=p;
y3=q;
k=k+1;
end
end
end
if(flag_see==1)
xi=x3;
yi=y3;
else
xi=p;
yi=q;
end
if k==0
break
end
end
% xi=x1;
% yi=y1;
end
end
end
end
xi=x1;
yi=y1;
if k==0
break
end
end
end
% figure,subimage(wind);
%to count 0-1, 0-2, 0-3 transition around the boundary clkwise
T=1;
for v=1:3
T0v=0;
r=x-wl;
for c=y-wl:y+(wl-1)
if (wind(r,c)==0)&&(wind(r,c+1)==v)
T0v=T0v+1;
end
end
c=y+wl;
for r=x-wl:x+(wl-1)
if (wind(r,c)==0)&&(wind(r+1,c)==v)
T0v=T0v+1;
end
end
r=x+wl;
for c=y+wl:-1:y-(wl-1)
if (wind(r,c)==0)&&(wind(r,c-1)==v)
T0v=T0v+1;
end
end
c=y-wl;
for r=x+wl:-1:x-(wl-1)
if (wind(r,c)==0)&&(wind(r-1,c)==v)
T0v=T0v+1;
end
end
T1=T0v==1;
T=T & T1;
end
if T~=1
minutiae_valid(i,:)=[0 0 0 0];
combined(x,y,:)=[255,255,255];
end
end
end
minu_count=1;
minutiae_valid_final(minu_count, :) = [0,0,0,0]; %to make x, y, CN, theta value of minutiae not in border region.
for i=1:totminu_I
CN = minutiae_valid(i,3);
if (CN~=0)
minutiae_valid_final(minu_count, :) = minutiae_valid(i,:);
minu_count = minu_count + 1;
end
end
% totminu_I= minu_count-1;
minutiae_valid = minutiae_valid_final;
% figure, subimage(combined);
答案 0 :(得分:2)
在第212和213行,您可以创建嵌套循环,循环遍历九个风元素,寻找符合某种条件的元素。找到一个时,可以更改九个元素块的中心。
当你的街区中心位于风的边缘时会出现问题。当您查看以边缘为中心的九个元素时,您不能以相同的方式访问索引,否则您将得到如上所述的错误。为了说明一个简单的例子:
a = rand(4,4);
for p=2:4
for q = 1:3
tmp += a(p,q)
end
end
对以(3,2)为中心的(正方形数组)的9个元素求和。
a = rand(4,4);
for p=3:5
for q = 1:3
tmp += a(p,q)
end
end
将生成与尝试访问(5,1)时相同的错误,因为该数组的元素不存在。解决这个问题的正确方法取决于你想要做什么,但这绝对超出了你的问题的范围,以及我们弄清楚的能力。
我希望这会有所帮助。
回应一些评论,我想为您提供一些建议。将来,如果您可以将问题归结为最短的测试用例,那么您更有可能获得优质答案。这也是调试自己的代码的一个有价值的步骤。弄清楚如何构建测试用例通常可以明显解决您的问题。当它不明显时,Stackoverflow是一个很好的资源。