i have error in bifurcation

2 vues (au cours des 30 derniers jours)
preethi
preethi le 12 Fév 2014
clc
clear all
close all
I=imread('pat.bmp');
X=im2double(I);
J = histeq(X);
subplot(4,1,1)
imshow(X)
title('input fingerprint');
subplot(4,1,2)
imshow(J)
title('histogram eq');
subplot(4,1,3)
imhist(X,64)
title('hist of X');
subplot(4,1,4)
imhist(J,64)
title('hist of J');
%WEINER FILTER
K = wiener2(J,[5,5]);
figure,imshow(K)
title('weiner filter')
%BINARISATION
K1=I(:,:,1)>160;
figure,imshow(K1)
title('binarization')
set(gcf,'position',[1 1 600 600]);
%%%%% MORPHOLOGICAL OPERATION %%%%%
%CLEAN
K2=bwmorph(~K1,'clean','inf');
figure,imshow(~K2)
title('CLEAN')
set(gcf,'position',[1 1 600 600]);
%HBREAK
K3=bwmorph(~K2,'hbreak','inf');
figure,imshow(~K3)
title('HBREAK')
set(gcf,'position',[1 1 600 600])
%SPUR
K4=bwmorph(~K3,'spur','inf');
%figure,imshow(~42)
% title('SPUR')
set(gcf,'position',[1 1 600 600]);
%THINNING
K5=bwmorph(~K4,'thin','inf');
figure,imshow(~K5)
title('Thinning')
set(gcf,'position',[1 1 600 600]);
fun=@(minutie) median(minutie(:));
L = nlfilter(K5,[3 3],fun);
figure,imshow(~L)
%%Termination
LTerm=(L==1);
imshow(LTerm)
LTermLab=bwlabel(LTerm);
propTerm=regionprops(LTermLab,'Centroid');
CentroidTerm=round(cat(1,propTerm(:).Centroid));
imshow(~K5)
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')
  3 commentaires
preethi
preethi le 13 Fév 2014
when i run this coding i can able to get the output for termination but bifurcation the error is showing at plot(centroidBif... can u plz explain a way to clear this problem
Walter Roberson
Walter Roberson le 13 Fév 2014
As we indicated to you in http://www.mathworks.co.uk/matlabcentral/answers/115794-problem-with-this-code you need to give us the full error message.
Please also show us size(CentroidBif) and size(propBif) and size(propBif(1).Centroid)
Oh yes, also show us size(LBif) and nnz(LBif)

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 13 Fév 2014
You have
K5=bwmorph(~K4,'thin','inf');
Whatever K4 is, ~K4 is going to be datatype logical, so numerically 0 and 1 values. You apply median to those values, so your result is going to be 0 or 1. (If your window was an even size then you could also end up with 0.5, but your window is not even.)
Then you have
LBif=(L==3);
but I just showed that L is only 0 and 1's, so no L are 3, so LBif will be an array of all false.
bwlabel applied to all false is going to result in nothing labeled.
regionprops applied to nothing labeled is going to find no regions, so it is going to return the empty array.
cat'ing together the empty arrays is going to give you an empty array.
Attempting to access (:,1) or (:,2) of an array that is 0 x 0 (or 1 x 0 or 0 x 1) is going to give you a "subscript out of range" error.

Community Treasure Hunt

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

Start Hunting!

Translated by