A technique for automatically generating a virtual model of a branched structure using as an input a plurality of images taken of the branched structure. The technique employs an algorithm that avoids inaccuracies associated with sub-optimal threshold settings by “patching” holes or leaks created due to the inherent inconsistencies with imaging technology. By “patching” the holes, the algorithm may continue to run using a more sensitive threshold value than was previously possible.