<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.6944.0">
<TITLE>RE: [Insight-users] Connected component statistics</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT SIZE=2 FACE="Courier New">Hi Jim/Richard,</FONT>
<BR><FONT SIZE=2 FACE="Courier New">I like the idea of using std::map<itk::CommponentStatistics> type storage. The first entry of the map (the Key) could be the component label index. It would probably be desirable to assign label for each of the connected components in descending order of their size (as it is done in the current filter).</FONT></P>
<P><FONT SIZE=2 FACE="Courier New">Sayan</FONT>
</P>
<P><FONT SIZE=2 FACE="Courier New">> Date: Tue, 19 Jul 2005 09:18:11 -0400</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> From: "Miller, James V (Research)" <millerjv@crd.ge.com></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> Subject: RE: [Insight-users] Connected component statistics</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> To: <Richard.Beare@ieee.org></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> Cc: insight-users@itk.org, Karthik Krishnan</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> <Karthik.Krishnan@kitware.com></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> Message-ID:</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> <FA26BEF1EA775E4584FB34B91E14A1C403F34F82@SCHMLVEM01.e2k.ad.ge.com></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> Content-Type: text/plain; charset="iso-8859-1"</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> Richard, </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> A one pass algorithm is what I would want ITK to have to compute these</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> statististics for all components. Glad to hear you were already thinking</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> along those lines.</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> As for a representation, I would start with an approach like the RelabelComponentImageFilter</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> and LabelStatisticsImageFilter. After these filters run, you can query the filter for </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> the statistics of interest for a given component.</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> If this information needs to flow through the pipeline, then a separate data structure, </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> say a std::map<itk::ComponentStatistics> could be used and wrapped with a DataObjectDecorator</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> to add a DataObject API to the std::map. We would still have to create an itk::ComponentStatistics</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> class (or some other named class) to store the statistics for a given component.</FONT>
</P>
<P><FONT SIZE=2 FACE="Courier New">> Jim</FONT>
</P>
<P><FONT SIZE=2 FACE="Courier New">> > -----Original Message-----</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > From: Richard Beare [</FONT><A HREF="mailto:richard.beare@gmail.com"><U><FONT COLOR="#0000FF" SIZE=2 FACE="Courier New">mailto:richard.beare@gmail.com</FONT></U></A><FONT SIZE=2 FACE="Courier New">]</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > Sent: Monday, July 18, 2005 7:37 PM</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > To: Miller, James V (Research)</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > Cc: Gaetan Lehmann; Karthik Krishnan; insight-users@itk.org</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > Subject: Re: [Insight-users] Connected component statistics</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > Hi everyone,</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > It seems that there are a few starting points around already. The</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > measures we computed in my previous job could all be done in a single</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > pass and consolidated at the end. I think that most of them have</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > already been covered in the discussion.</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > The only thing I'm not sure about now is an ITK specific question -</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > how should the statistics be represented. The previous function of</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > this type that I used produced a table of statistics as output, with</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > one row for each connected component. This table was easily</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > represented as an image. I suspect that this approach wouldn't be</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > appropriate in ITK, but I'm not sure what the right mechanism is,</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > since I'm still learning my way around.</FONT>
</P>
<P><FONT SIZE=2 FACE="Courier New">On 7/18/05, Miller, James V (Research) <millerjv@crd.ge.com> wrote:</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> Gaeton,</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> Center of gravity and bounding box could be added to the RelabelStatisticsImageFilter</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> since they are simple calculations. However, it is a bit of a side-effect. The</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> volume is calculated in the RelabelStatisticsImageFilter because it is used by the</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> filter to order the labels. Since it was already calculated, it made sense to allow</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> the user to access it.</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> The best place for these measures and the more complicated measures would be a class</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> similar to the LabelStatisticsImageFilter. The filter should be called something like</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> LabelMomentsImageFilter (and calculate ImageMoments as well as geometric moments. Or maybe</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> something like LabelShapeImageFilter.</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> I do not see any reason to use the ImageSpatialMaskObject for this task. Usually, you</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> would want to calculate these features for EVERY component. So it best to run through a</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> filter that does it.</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> Jim</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> -----Original Message-----</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> From: Gaetan Lehmann [</FONT><A HREF="mailto:gaetan.lehmann@jouy.inra.fr"><U><FONT COLOR="#0000FF" SIZE=2 FACE="Courier New">mailto:gaetan.lehmann@jouy.inra.fr</FONT></U></A><FONT SIZE=2 FACE="Courier New">]</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> Sent: Monday, July 18, 2005 4:57 AM</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> To: Miller, James V (Research); Karthik Krishnan; Richard.Beare@ieee.org</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> Cc: insight-users@itk.org</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> Subject: Re: [Insight-users] Connected component statistics</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> Hi,</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> I'm also interested in basic measures such as volume, center of gravity</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> and bounding box.</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> I think to work on it this week, so it should be great to define where to</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> implement methods to get those informations.</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> RelabelComponentImageFilter is already able to give volume, so it should</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> be a good place to add other very simple informations like center of</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> gravity and bounding box.</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> It don't seem to be the good place for more complex info such as</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> perimeter/surface... perhap's ImageMaskSpatialObject is a better place ?</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> WDYT ?</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> Gaetan</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> On Fri, 15 Jul 2005 20:39:46 +0200, Miller, James V (Research)</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> <millerjv@crd.ge.com> wrote:</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > The LabelStatisticsImageFilter will calculate statistics for each</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > component.</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > Currently, the LabelStatisticsImageFilter calculate mean, variance, sum,</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > count,</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > and histograms.</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> ></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > We plan to add another filter that calculated the moments (either image</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > moments or</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > geometric moments) of each component. I have been waiting for it to be</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > completed and</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > may have to just write it myself.</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> ></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > Also, the RelabelComponentImageFilter allows you to query the volume of</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > a component.</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> ></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > Jim</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> ></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > -----Original Message-----</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > From: insight-users-bounces+millerjv=crd.ge.com@itk.org</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > [</FONT><A HREF="mailto:insight-users-bounces+millerjv=crd.ge.com@itk.org]On"><U><FONT COLOR="#0000FF" SIZE=2 FACE="Courier New">mailto:insight-users-bounces+millerjv=crd.ge.com@itk.org]On</FONT></U></A><FONT SIZE=2 FACE="Courier New"> Behalf Of</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > Karthik Krishnan</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > Sent: Friday, July 15, 2005 10:10 AM</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > To: Richard.Beare@ieee.org</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > Cc: insight-users@itk.org</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > Subject: Re: [Insight-users] Connected component statistics</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> ></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> ></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> ></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> ></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > Richard Beare wrote:</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> ></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> >> Hi,</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> >></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> >> I've found ConnectedComponentImageFilter and</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> >> RelabelConnectedImageFilter, but I haven't been able to find anything</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> >> that returns measures of the connected components -- e.g. area/volume,</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> >> perimeter/surface area, centre of gravity, ellipse moments and minimum</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> >> enclosing rectangles.</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> >></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> >></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > You could threshold the labelled image to get each connected component</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > and...</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> ></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > If you are using CVS ITK, I had put a method recently :</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > ImageMaskSpatialObject::GetAxisAlignedBoundingBoxRegion()</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > that computes the minimum axis aligned bounding box of a 3D binary image.</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> ></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > ImageMomentsCalculator can help you with moments, CG etc.</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> ></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > An appropriate class to add methods to compute volume, perimeter,</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > surface area etc may be theImageMaskSpatialObject class . You could</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > write them and put them back into ITK :)</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> ></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > I don't think ITK has many CAD measurement methods.</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> ></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> >> Also, what is the recommended approach for making greyscale measures</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> >> of regions defined by a connected component image?</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> >></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> >> Thanks</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> >></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> >> Richard</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> >> _______________________________________________</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> >> Insight-users mailing list</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> >> Insight-users@itk.org</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> >> </FONT><A HREF="http://www.itk.org/mailman/listinfo/insight-users"><U><FONT COLOR="#0000FF" SIZE=2 FACE="Courier New">http://www.itk.org/mailman/listinfo/insight-users</FONT></U></A>
<BR><FONT SIZE=2 FACE="Courier New">> >></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> >></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> >></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > _______________________________________________</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > Insight-users mailing list</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > Insight-users@itk.org</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > </FONT><A HREF="http://www.itk.org/mailman/listinfo/insight-users"><U><FONT COLOR="#0000FF" SIZE=2 FACE="Courier New">http://www.itk.org/mailman/listinfo/insight-users</FONT></U></A>
<BR><FONT SIZE=2 FACE="Courier New">> > _______________________________________________</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > Insight-users mailing list</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > Insight-users@itk.org</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> > </FONT><A HREF="http://www.itk.org/mailman/listinfo/insight-users"><U><FONT COLOR="#0000FF" SIZE=2 FACE="Courier New">http://www.itk.org/mailman/listinfo/insight-users</FONT></U></A>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> </FONT>
<BR><FONT SIZE=2 FACE="Courier New">> --</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> Gaetan Lehmann <gaetan.lehmann@jouy.inra.fr></FONT>
<BR><FONT SIZE=2 FACE="Courier New">> Tel: +33 1 34 65 29 66</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> Biologie du Développement et de la Reproduction</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> INRA de Jouy-en-Josas (France)</FONT>
<BR><FONT SIZE=2 FACE="Courier New">> Web: </FONT><A HREF="http://voxel.jouy.inra.fr"><U><FONT COLOR="#0000FF" SIZE=2 FACE="Courier New">http://voxel.jouy.inra.fr</FONT></U></A>
<BR><FONT SIZE=2 FACE="Courier New">></FONT>
</P>
</BODY>
</HTML>