How to select the highest number of branches/branch points?

good day I want to detect branches by applying 8 component and find the branch with highest pixel. i tried first with finding the branch points..but since there are many branch split i could not perform the operation i needed can somebody help me . so far i have tried this..with this i get a image with all branch points
bp =bwmorph(vesimg,'branchpoints')
[row column] = find(bp)
branchPts = [row column]
figure;imshow(vesimg);
hold on ;
plot(branchPts(:,2),branchPts(:,1),'+');
% branches = mn;
% branchesLabeled = bwlabel( branches, 8 )% label connected components
% sts = regionprops( branchesLabeled, 'Area', 'Perimeter' )
my input image is

Answers (1)

One way to approach this would be to:
  1. First, remove the branchpoints from the skeleton image (dilate them first to make sure you sever the branches in 8-connectivity on)
  2. Now loop over branch points and add them back in. Do a connected components analysis (bwconncomp) and look at the NumObjects field of the connected components structure. The number of branches connected to each branch point is the original number of objects (image without branchpoints) subtracted from the number of objects in the image with that branchpoint restored.
Pseudocode
skeletonize
branchpoints
dilate branchpoints
ccbranches = bwconncomp(dilated branchpoints)
number of branchpoints = ccbranches.NumObjects
vessel without branches = vessel
vessel without branches(dilate branchpoints) = 0
cc = bwconncomp(vessel without branches)
Noriginal = ccbranches.NumObjects;
for ii = 1:number of branch points
X = vessel without branches
X(branchii) = true;
ccii = bwconncomp(X);
numbranches(ii) = ccii-Noriginal
end
[maximumbranches,index] = max(numbranches)

12 Comments

sir..your code seem to work but here i get a error in branch(ii); error says
??? Error using ==> branch at 112
first input argument must be either a TREE or an LTI created by MKSYS
and also i calculated branch points using
sk = bwmorph(BW2,'skel');
mn=bwmorph(sk,'branchpoints');
[row column] = find(mn);
branchPts = [row column];
%e = strel('disk',1,4);
% dil=imdilate(branchPts,se);
% imshow(dil); ///// i get empty image here donno
can i please know what is it all about.. i am new to "branch" function
and also ccii is to be a structure ..how can i minus it with a matrix..caaan u please explain me
My code was pseudocode outlining the idea.
sir... i solved all the errors ..but just for the "branch: function can u please help me
sir ..i follwed your pseudo code but could not get these lines.. can u please please help me
X(branchii) = true;
ccii = bwconncomp(X);
numbranches(ii) = ccii-Noriginal
end
[maximumbranches,index] = max(numbranches
That code was actually pretty-non-pseudoish. Copyu and paste it.
X = vessel_without_branches; % whatever variable this is,
sir sorry for being silly but X = vessel_without_branches; is working fine with me.. but
X(branch(ii)) = true;
//this gives me error saying
??? Error using ==> branch at 112
first input argument must be either a TREE or an LTI created by MKSYS
Apparently, you have not defined a variable branch so MATLAB is calling the obsolete Robust Control Toolbox function branch
Not all your branches extend out without overlap from the optic nerve. Many branches seems to connect with other branches, forming loops. What do you plan to do about that?
Image Analyst, sir, my plan is to
  1. select the branch with most vessels since most of the vessel split up from optic disc . if there are several branches with highest number of connections then the branch with most pixel is selected .
  2. taking bounding box of most vessel connections
  3. centre of the bounding box vl be "optic disc"
@ Sean de Wolski..sir m sorry for being so foolish i thought that "branch " is some function which helps in branching sorry sir
By my count, if you cut out the optic disk, then you have only two major branches that are separate. In each of those two there are numerous other branches that are connected into loops. I don't see what your plan does. How are you going to count the number of vessels on each branch? Are you going to count the endpoints of the skeleton? This plan does not look well thought out, to me at least.
@IA, Are you referring to Vidya's plan or my pseudocode above?
@ image Analyst...sir i worked out a research paper and found a method ..and was successfully able to extract optic disc. The problem it works for many images but not for all..can u please help me to improve my code

Sign in to comment.

Asked:

on 10 Mar 2014

Commented:

on 12 Mar 2014

Community Treasure Hunt

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

Start Hunting!