# Integrating digital topology in image-processing libraries

Post on 05-Sep-2016

216 views

TRANSCRIPT

computer methods and programs in b iomed ic ine 8 5 ( 2 0 0 7 ) 5158journa l homepage: www. int l .e lsev ierhea l th .com/ journa ls /cmpbIntegr -Julien LaIrcad, 1, Plaa r t i cArticle historReceived 14Received in28 August 2Accepted 28Keywords:Digital topoImage-procITKCode generitoal, forst ie sarms asls oge-p1. IntroductionDigital imathough sigtal images,account thaanymore buimages.This dislevel, as moon an imaglogical levebase of topcontinuoustopologicalwhen appliAlgorithous, from c[1] or loop rical imagelibraries, ITduring the Tel.: +33E-mail acauses of course a loss of exibility, but also a loss of coher-0169-2607/$doi:10.1016/ge processing is by nature a discrete process:nal processing algorithms can be applied to digi-they have to be adapted in some way to take intot the image they process is not a continuous signalt a set of pixels, or of voxels for three-dimensionalcrete nature causes few problems at the geometricst of the geometric operations that can be appliede are independent of the underlying grid. At a topo-l, this is however different. The notion at the veryology, the neighborhood, is radically different fromspaces to discrete spaces. This leads to continuousalgorithms not respecting topological constraintsed on a digital grid.ms based on topological information are numer-onnected component labeling to skeletonizationemoval, all of which are used in the eld of med-processing [24]. In two major image-processingK [5] and Vigra [6], the type of neighborhood usedalgorithm is hard-coded in that algorithm. This388 119 079; fax: +33 388 119 099.ddress: julien.lamy@ircad.u-strasbg.fr.ence when processing both the foreground and the back-ground of a digital image, as it is a well-known fact thattwo different connectivities must be used for the backgroundand the foreground [7]. If this condition is not respected, theJordan theorem [8] will not hold and situations will arisewhere a closed curve does not partition the space in tworegions.This rigid characteristic of those both major libraries isdue to the lack of pertinent data structures to correctly rep-resent the topology of digital images. In this paper, we showhow to integrate the digital topology information in an image-processing library in a way that is: generic, with respect to both the image dimension and thedifferent types of neighborhood; automated, in the sense that as few special case code aspossible has to be written; fast, by pre-computing as many things as possible.The language used in this paper is C++, as this work wasrealized within the ITK framework. However, the concepts see front matter 2006 Elsevier Ireland Ltd. All rights reserved.j.cmpb.2006.08.006ating digital topology in imagemy ce de lHopital, 67091 Strasbourg Cedex, Francel e i n f oy:February 2006revised form006August 2006logyessing librarycitya b s t r a c tThis paper describes a methodprocessing libraries. This additionrespecting topological constraintsdigital topology is absent from mofullled. We describe and give codtion, and show a use case in the folter can be up to a hundred timedimension. This paper mainly deaminor modications to other imaprocessing librariesintegrate digital topology informations in image-information allows a library user to write algorithmsexample, a seed ll or a skeletonization algorithm. Asmage-processing libraries, such constraints cannot bemples for all the structures necessary for this integra-of a homotopic thinning lter inside ITK. The obtainedfast as ITKs thinning lter and works for any imagef integration within ITK, but can be adapted with onlyrocessing libraries. 2006 Elsevier Ireland Ltd. All rights reserved.52 computer methods and programs in b iomed ic ine 8 5 ( 2 0 0 7 ) 5158explained here could easily be adapted to other languages,and other image-processing libraries.We willprocessingtopology, apresent thein an imageuse these stion algoritgiving lead2. PreIn this sectlack the neogy in the iIn ITK, talgorithmsneighborhoin two-dimit is not poground andIn Vigrathe Neighblimited toeight-connis not an etreated ascode everyby the numThe lackimage-proceven impoconstraints3. DiWe will nothe notatioframeworkof the imagdecomposiIn this rrepresenterelations, ror voxels (c3.1. CelLet us condened as Ii is eithe k of the nare of thThe dimz1 + 1[ ]z2,the image, Cells in R2, with underlying digital grid andnates. Green: 0-cells (vertices); yellow: 1-cells (edges);-cells (faces). (For interpretation of the references toin this gure legend, the reader is referred to theersion of the article.)ilarlrtexraph. 1 anng the havll: vell: edlls: flls: swillthethei if Iizi 1 Cells in R3. Green: 0-cells (vertices); yellow: 1-cells); blue: 2-cells (faces); red: 3-cells (solids). (Forretation of the references to colour in this gure, the reader is referred to the web version of the.)rst present the limitations of two major image-libraries, ITK and Vigra, with respect to digitalnd detail the theoretical background. We will thennecessary structures to integrate digital topology-processing library, and give an example on how totructures to implement a homotopic skeletoniza-hm. We conclude by summarizing our work and bys for future improvements.vious workion, we show how both the ITK and Vigra librariescessary structures to correctly embed digital topol-mages and algorithms.here is no structure related to digital topology. Alluse a hard-coded neighborhood, usually the 18-od in three-dimensions, and the 4-neighborhoodensions. As these neighborhoods are hard-coded,ssible to use coherent connectivities for the back-the foreground., there is a basic support for digital topology, usingorhoodCirculator class. This class is howevertwo-dimensional images and treats the four- andectivity in a non-generic way. In our sense, thisasily maintainable solution: each connectivity isa special case. And as the developer has to hand-case, this multiplies the possible sources of errorsber of cases.of digital topology information in those twomajoressing libraries shows that it will be difcult, orssible, to write algorithms respecting topological.gital topology basicsw recall the basics of digital topology, and presentns used in the rest of the article. To ensure that ourwill be generic with respect both to the dimensione and the type of neighborhood, we will use a celltion representation [9].epresentation, a binary image of any dimension isd as a set of cells, with well-dened neighboringather that just a set of pixels (cells of dimension 2)ells of dimension 3).lssider images of dimension n. A k-cell of Rn [9] isa subset of Rn of the form c= I1 In such that:r of the form ]zi, zi +1[ or the form {zi} (zi Z);sets Ii are of the form ]zi, zi +1[ and the other n ke form {zi}.ension of a k-cell is k. A n-cell has the form ]z1,z2 + 1[ ]zn, zn +1[, and is thus a pixel/voxel ofoccupying a unit area/volume.Fig. 1coordiblue: 2colourweb vSimis a veA gin FigsUsithat w 0-ce 1-ce 2-ce 3-ceWeused incell c iswhere Ji = I Ji = ]Fig. 2(edgesinterplegendarticley, a 0-cell has the form {z1} {z2} {zn}, andof a pixel/voxel, of coordinates (z1, z2, . . ., zn).ical denition of the cells of R2 and R3 is presentedd 2.e more usual vocabulary of modeling, we can seee the following equivalences, up to three-cells:rtices;ges;aces;olids.now dene the open star of a cell, which will bedenition of connectivity. The open star St(c) of a k-smallest open set containing c, i.e. St(c) = J1 Jn= ]zi, zi +1[,, zi +1[ if Ii = {zi}.computer methods and programs in b iomed ic ine 8 5 ( 2 0 0 7 ) 5158 53Fig. 3 Open stars of 0-cell (vertex, left) and 1-cell (edge,right) in R2.From this denition,we can see that the open star of a k-cellc contains the cell c as well as every -cell adjacent to c suchthat k R2 can be s3.2. ConThis cell dedenition arespect toneighborhoLet di becells (i.e. piexist a dj-ceAs shoneighborho1)-neighborlarly, in threto the 26-nto the 18-nlent to theUsing thent possiblcan also sedj coordinawhich diffedj)-neighbo(didj)2didThis resultbors in a laFig. 4 (2,0(right).Table 1 Equivalences between connectivities expressedwith usuaRegular co4, in two di8, in two di6, in three18, in three26, in threeSimtheom th1 andkdsamd inJorcont(i.e. non-overlapping) closed surface divides the spaceparts, the interior and the exterior. In a discrete space,ding on how the connectivities are chosen for the fore-and the background, this theorem can be invalidated.ple closed curved show in Fig. 5 intuitively divides thein two parts. However, if the curve is (2, 0)-connectede background is also (2, 0)-connected, the backgroundore divided in two parts. In the opposite case, i.e. the (2,nectivity is used for the background and the foreground,ckground has two components, but the curve enclosingt closed anymore.as beenproven [10] that the (di, di 1)-connectivitymustd either for the foreground or the background. The (di,nectivity is usually chosen for the other connectivity.n. A graphical representation of the open stars ineen in Fig. 3.nectivitycomposition and the open star denition yields and a notation of connectivity that is generic withboth the dimension of the image and the type ofod.the dimension of the image. We say that two di-xels or voxels) c1 and c2 are (di, dj)-neighbors if therell (dj 54 computer methods and programs in b iomed ic ine 8 5 ( 2 0 0 7 ) 5158numbers, which characterize the topology of a point in animage.4.1. ConWehave seinition basularly suiteby the dimof the cell cWewanof the progruser and tto a given cgram. We ato each conof a given cThe statconnectivitOur connecthe dimensthe cell contype shownThe autachieved usyntax, theof a pointerof the connachieved bmentation4.1.1. FeaOnce theshown aboconnectivitof neighborThe arrathe rst crgiven in Eqof the originset to 0, anprovided foFor algoto access cimplementif its argumThe second test, built on the rst one, returns true if its twoarguments are (di, dj)-neighbors.inteBar toelperb asned(cf, cbegrodi 1we agramtiondConcontatedIn thi.e. 2condimehe fofer trtialnitctivitundingnectivityen in the previous section that the connectivity def-ed on cell decomposition allows a notation partic-d for programming: a connectivity is fully denedension of the image and the minimum dimensiononnecting two pixels/voxels.t the connectivity to be fully operational at the startam no special initialization should be done by theo be a constant object, as the neighbors associatedonnectivity should not be changed during the pro-lso wish that there is exactly one object associatednectivity, as there should not be several instancesonnectivity.ic aspect of the dimensions that parameterize they ismapped to static polymorphism, i.e. templates.tivity object is thus templated by two parameters,ion of the image and the minimum dimension ofnecting two pixels/voxels, which gives the proto-below, uint meaning here unsigned int.omated initialization and the unique instance aresing the singleton design pattern [11]. For an easiersingleton returns a reference to the object, instead. The next code fragment shows the singleton partectivity object interface. Note that the constness isoth in the interface (public part) and in the imple-(private part):tures of the connectivity objectbasic requirements are met using the methodsve, we can add the connectivity information to they object. This information is composed of an arraypoints and two tests.y of neighbor points is automatically computed oneation of a connectivity object, using the results. (1). It is lled by every point in the neighborhood, i.e. points whose coordinates have dj coordinatesd di dj coordinates set to +1 or 1. This array isr algorithms that need to scan every neighbor.rithms that do not scan every neighbor but needonnectivity information for a particular point, weed two connectivity tests: the rst test returns trueent is in the (di, dj)-neighborhood of the origin.The4.2.In ordevide htivity cmentioin thethe foras (di,di 1),Procializagrounwhichassocibelow.(3, 2) (groundthree-In twill reThe parst deconneforegroremainrface for these features is shown below:ckground connectivitysimplify the use of the connectivity class, we pro-s to automatically dene the background connec-sociated to a given foreground connectivity cf. Asabove, the (di, di 1) connectivity must be present) couple for the Jordan theorem to be respected. Ifund connectivity is not (di, di 1), then we dene cb). Otherwise, i.e. the foreground connectivity is (di,rbitrarily dene cb as (di, 0).ming-wise, we achieve this by using partial spe-of templates [12]. We dene a class named Back-nectivity, templated by a connectivity type,ains the typedef for the background connectivitywith the parameter. A simple use-case is givenis example, the foreground connectivity is set to6-connectivity in three-dimension), and the back-nectivity is then set to (3, 0) (i.e. 6-connectivity innsion):llowing, the abbreviations FGC end BGC in the codeo the foreground and background connectivities.template specialization we use is shown next. Theion is the main template, setting the backgroundy to (di, di 1). The special cases, i.e. when theconnectivity is (di, di 1) are expressed by the twodenition:computer methods and programs in b iomed ic ine 8 5 ( 2 0 0 7 ) 5158 55Note that the specialization for the case cf = (di, di 1)is explicit for each dimension. This is due to a currentdrawback otemplate aon whichfully this lilanguage.This helby the forebility, andease of usebelow:4.3. TopAfter havinogy, we canputation oMalandaindene theps neighbo(3,2)- and tdened asT(3,2)(p, I) =T(3,0)(p, I) =where #Cpc (X which arneighborhoThedethat the strof T(3,2): theand thus doapplies in twis not (2, 1)-be scannedIn a simnectivity, wwhich neigcounted. Tdescribedity cf, we wborhood:comhelpf po:nd p2cn-asumoriginng thate azednnecterfahe un annctiogenen imApsecres tITKf the C++ language, as it is forbidden to have argument (here di 1) depending on an argumentthe template is specialized (here di) [12]. Hope-mitation will be lifted in the next version of theper class allows to template a topological algorithmground and background connectivities, for exi-to make use of default template parameters, for. Such an example is shown in the code fragmentological numbersg designed a basic class representing the topol-easily build more elaborate tools, like the com-f topological numbers. Dened by Bertrand and[13], the topological numbers are an easy way totopology of a point p inside an image I, using onlyrhood. In three-dimension, using respectively thehe (3, 0)-connectivity for the foreground, they are#Cp(3,2)(N(3,1)(p) I),#Cp(3,0)(N(3,0)(p) I)X) is the number of c-connected components ine c-adjacent to p, and where Nc (p) is the strict c-od of p (i.e. it excludes p).nition is similar for the two-dimensional case. Noteict (3, 1)-neighborhood is used for the computationstrict (3, 2)-neighborhood is not (3, 2)-connectedes not carry enough information. The same thingo-dimension,where the strict (2, 1)-neighborhoodconnected, and the strict (2, 0)-neighborhoodmust.ilar way as what we did for background con-e dene a helper to automatically determine inhborhood the connected components must behat NeighborhoodConnectivity helper class isbelow. Depending on the foreground connectiv-ill note cn the connectivity used for the neigh-Toble, apairs oments p1 a p1 is thetheUsiily creoptimithe coThe inclass, tfunctiober fube asfrom aarray.5.In thisstructulter inpute the topological numbers as fast as possi-er is dened whose role is to pre-compute allints (p1, p2) which satisfy the following require-are cf-adjacent,djacent to the origin,p1 +p2 is within a cube of size 333 centered at.is helper, called UnitCubeNeighbors, we can eas-seed-ll algorithm, respecting the topology andfor a 333 image, and thus efciently countted components in the neighborhood of a point.ce of that seed-ll is given below. To use thisser assigns the image using the SetImage memberd then calls the operator. The SetImage mem-n takes two iterators as parameters in order toric as possible: that data might not only comeage, but also from other sources, e.g. a plain Cplication to ITKtion, we show how to use the previously denedowrite a generic and efcient homotopic-thinning.56 computer methods and programs in b iomed ic ine 8 5 ( 2 0 0 7 ) 51585.1. Homotopic thinningHomotopic thinning extracts a thin skeleton from an object,with the adto the origiprocess is slayers of voIn orderpoints, i.e.ogy, are reabove, a poThe skeletooriginal obwe obtainest subsetconnectedtopic kerneand topoloare not termdependenthave only oterminalitya surfacic sTo integone to comand one tobeing straighere.5.2. TopTheprototyis given belThe Image template parameter is usual among ITK l-ters and functions and wont be discussed here. The functionobject is temity ofhelpinteinteers otimes funnctioSkeothenizaity. Tdelity, ohey cweveusesn chrt ofthinal toed wcomingIs. Thwhicwo-dst imal sTestis 11fastesultsllustimagditional property that the skeleton is homotopicnal object, i.e. both have the same topology. Thisimilar to peeling an onion, as it iteratively removesxels from the object [14].to satisfy the homotopy requirement, only simplepoints whose removal does not change the topol-moved. Using the topological numbers describedint is simple if and only if Tcf = 1 and Tcb = 1 [13].nmust also keep geometrical characteristics of theject. If no geometrical characteristic is preserved,what is known as the homotopic kernel, the small-homotopic to the original object. For any simply(i.e. without tunnel nor cavity) object, the homo-l is a single point. The preservation of geometrygy is achieved by removing simple points, whichinal. The denition of terminality is application-: if a skeleton formed of lines is wanted, points thatne neighbor in the foreground will be kept. Othercriteria exist to preserve surface patches and getkeleton [15].rate this in ITK, we created two function objects:pute the topological numbers of apoint in an image,decide the terminality of a point. The latter onehtforward, only the former one will be describedological numbers function objectspeof our topological numbers functionobject classow:nectivby thepair ofuser ismembcutionThirion fu5.3.As forskeletonecitivcriteriaexibiteria: tare hoterioncriterioing paTheremovcenterWeThinnimagening,Two tITK temetricWhiteltertimestion reFig. 6.To iof theplated by the foregroundand thebackground con-the image, the latter having a default value givener describer earlier. This function object returns agers, equal to (Tcf , Tcb ) at the chosen point. If therested only in computing Tcf or Tcb , two booleanf the class can be set to false in order to save exe-.ction object is then used to derive a boolean crite-n object to determine the simplicity of a point.letonization lterr structures that need topological informations, thetion lter class is templated by the foreground con-his template parameter is then passed to the twoned above (simplicity and terminality). To allow forur skeletonization lter does not hardcode the cri-an be set by the user, using functors. Default valuesr provided for ease of use: the default simplicity cri-topological numbers, and the default terminalityaracterizes line-terminal points. The correspond-the interface is shown below:ning is then performed using a distance-orderedguarantee that the resulting skeleton is correctlyith respect to the object [16].pared the results of our lter to ITKs Binary-mageFilter, which is limited to two-dimensionalis lter is based on morphological image thin-h does not include topological constraints [17].imensional test images were used, both fromages. The rst one (Shapes.png) depicts geo-hapes, the second one (ConnectedThreshold-.png) depicts white matter in the brain. Our6 times faster on the shapes image, and 6.5r on the white matter image. The skeletoniza-and their comparison to ITKs lter are shown inrate the independence of our lter to the dimensione, we also tested it on three-dimensional images,computer methods and programs in b iomed ic ine 8 5 ( 2 0 0 7 ) 5158 57Table 2 executionImageShapesWhite matStanford buLiverColonTime in s.one of theshown in FOn eachthe object, rwhich accotimes, meaare reporte6. DiWe have slack of digFig. 6 Two-dimensional objects and skeletons (original, aFig. 7 Three-dimensional objects anComparison of ITKs lter vs. authors ltertimesForegroundvoxelsAuthorsthinningITKsthinning1,537 0.02 2.32ter 9,215 0.08 0.52nny 1,623,669 59.9 N/A125,606 4.3 N/A5,139,339 171.5 N/AStanford bunny, one of a liver, and one of a colon,ig. 7.image, we can see that the skeleton is centered inespect the original topology andhas side branches,unt for the geometrical characteristics. The run-sured on a AMDOpteron 270 CPUwith 4GB of RAMd in Table 2.scussion and conclusionhown in this paper a method to overcome theital topology informations in image-processinglibraries, alconstraintssion of theity. As shoto a hundrFilter. Outhe InsightIts limittivities, whThis is howbe difcultanother feaWe propincrease thFirstly, wen-dimensiopler to exprless efciena translatioOnce the direspondingbe constandesign of sunectivity shimage.uthors thinning, ITK thinning).d skeletons.lowing to write algorithms respecting topological. Our method is generic with respect to the dimen-image and with respect to the type of connectiv-wn above, thinning using our method can be uped times as fast as ITKs BinaryThinningImage-r implementation of these classes are available inJournal [18].ation lies in the denition of the cb and cn connec-ich must be dened by the user for some values.ever a limitation of the C++ language, which will if not impossible to overcomewithout sacrifyingture.ose three further evolutions of our system, toe speed as well as the integration within ITK.plan to use image offsets instead of the actualnal coordinates. Neighborhoodoperations are sim-esswhen using n-dimensional coordinates, but aret, as the accesses to the image buffer will requiren from the coordinates of the point to an offset.mensions of the image are known, the offsets cor-to points coordinates can be computed, and willt as long as the image size is not modied. Thech a component is however not trivial, as the con-ould not depend on the structures used for the58 computer methods and programs in b iomed ic ine 8 5 ( 2 0 0 7 ) 5158Secondly, we propose to store the connectivity informationin the images themselves, instead of passing it as a parameterto the lters and functors. As the topology of an image remainsconstant throughout the lifetime of the image, it is the role ofthe image to know its topology, not the lter. In order to keepcompatibility with existing code, that parameter should havea default value.Thirdly, we propose to associate an iterator, similar to ITKsneighborhood iterators, to the image with connectivities. Aswith other iterator uses, this will allow to decouple the scan-ning method from the real work done by each algorithmiteration.r e f e r enc e s[1] L. Lam, S.-W. Lee, C.Y. Suen, Thinning methodologiesacomplete survey, IEEE Trans. Pattern Anal. Mach. Intell. 14(1992) 869885.[2] R. Justice, E. Stokely, J. Strobel, R. Ideker, W. Smith, Medicalimage segmentation using 3-D seeded region growing, in:Proceedings of the SPIE Symposium on Medical Imaging, vol.3034, 1997, pp. 900910.[3] I. Bitter, A.E. Kaufman, M. Sato, Penalized-distancevolumetric skeleton algorithm, IEEE Trans. Visual. Comp.Graph. 7 (3) (2001) 195206.[4] J. Lamy, C. Ronse, L. Soler, Loop removal from colon centralpath through skeleton scale-space tracking, in: G. Bebis, R.D.Boyle, D. Koracin, B. Parvin (Eds.), Proceedings of theAdvances in Visual Computing, First InternationalSymposium, ISVC 2005, Lake Tahoe, NV, USA, December 57,2005, pp. 6875.[5] L. Ibanez, W. Schroeder, L. Ng, J. Cates, The ITK SoftwareGuide, 1st ed., Kitware Inc., 2003, ISBN: 1-930934-10-6,http://www.itk.org/ItkSoftwareGuide.pdf.[6] U. Kothe, The VIGRA Reference Manual,http://kogs-www.informatik.uni-hamburg.de/koethe/vigra,2004.[7] A. Rosenfeld, J.L. Pfaltz, Sequential operations in digitalpicture processing, J. ACM 13 (1966) 471494.[8] G. Buskes, A. Van Rooij, Topological Spaces, Springer-Verlag,1997.[9] V.A. Kovalevsky, Finite topology as applied to image analysis,Comp. Vis. Graph. Image Process. 46 (1989) 141161.[10] G. Malandain, On topology in multidimensional discretespaces, Tech. Rep. 2098, INRIA, 1993.[11] E. Gamma, R. Helm, R. Johnson, J. Vlissides, Design Patterns:Elements of Reusable Object-Oriented Software,Addison-Wesley, 1995.[12] D. Vandevoorde, N.M. Josuttis, C++ TemplatesTheComplete Guide, Addison-Wesley, 2003.[13] G. Bertrand, G. Malandain, A new characterization ofthree-dimensional simple points, Pattern Recogn. Lett. 15(1994) 169175.[14] S. Lobregt, P.W. Verbeek, F.C.A. Groen, Three-dimensionalskeletonization: principle algorithm, IEEE Trans. PatternAnal. Mach. Intell. 2 (1980) 7577.[15] W.X. Gong, G. Bertrand, A simple parallel 3D thinningalgorithm, in: Proceedings of the 10th InternationalConference on Pattern Recognition, 1990, pp. 188190.[16] C. Pudney, Distance-ordered homotopic thinning: askeletonization algorithm for 3D digital images, Comput.Vision Image Understand. 72 (3) (1998) 404413.[17] R.C. Gonzales, R.E. Woods, Digital Image Processing, 2nd ed.,Prentice Hall, 2002.[18] J. Lamy, Digital topology, Insight J.,http://insight-journal.org/dspace/handle/1926/304.Integrating digital topology in image-processing librariesIntroductionPrevious workDigital topology basicsCellsConnectivityJordan theorem and background connectivityIntegration in an image-processing libraryConnectivityFeatures of the connectivity objectBackground connectivityTopological numbersApplication to ITKHomotopic thinningTopological numbers function objectsSkeletonization filterDiscussion and conclusionReferences

Recommended

View more >