<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
<BR>Hi, Luis.<BR>
&nbsp;<BR>
Thanks for the clarification.<BR>
My purpose is to build a signed distance function given a point clouds of a shape boundary. I know there are several options to do this. If the only input are those points, which is the best, fast and easiest way to do this? I know there are several options in ITK.<BR>
1.&nbsp; FastMarching.&nbsp; <BR>
2.&nbsp; Reinitiaze<BR>
3.&nbsp; DistanceMap (Danielsson).<BR>
&nbsp;<BR>
Another question would be regarding smart pointer and raw pointer.&nbsp; Is it OK to return a smart pointer from a function?<BR>
E.g. I have this code:<BR>
//////////////////////////////////////////////////////////////////////<BR>
main.cpp<BR>
typedef itk::Image&lt; unsigned char, 2 &gt; BinaryImageType;<BR>typedef itk::Image&lt; float , 2&gt; LSVImageType;<BR>LSVImageFilter::Pointer LSVImage =&nbsp; SDF(contour) // where the contour is binary image
&nbsp;<BR>
SDF.cpp<BR>
LSVImageType::Pointer SDF(BinaryImageType::Pointer contour)<BR>
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; typedef itk::SignedDanielssonDistanceMapImageFilter &lt; BinaryImageFilter,&nbsp;LSVImageFilter &gt; FilterType;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FilterType::Pointer filter = FilterType::New();&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;filter -&gt;SetInput ( contour ); // contour is the binary image&nbsp;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return filter-&gt;GetOutput();<BR>
}&nbsp;<BR><BR><BR>
//////////////////////////////////////////////////////////////////////<BR>
&nbsp;<BR>
&nbsp;<BR>
Thanks for any input<BR>
Siqi<BR>
&nbsp;<BR>
<BR>&gt; Date: Wed, 10 Dec 2008 15:16:08 -0500<BR>&gt; From: luis.ibanez@kitware.com<BR>&gt; To: pidanchen@hotmail.com<BR>&gt; CC: insight-users@itk.org<BR>&gt; Subject: Re: [Insight-users] SignedDanielssonDistanceMapImageFilter<BR>&gt; <BR>&gt; <BR>&gt; Hi Chensiqi,<BR>&gt; <BR>&gt; You are misinterpreting the behavior of this filter.<BR>&gt; <BR>&gt; If you have a binary image, where<BR>&gt; <BR>&gt; * The foreground object is set to 1 and<BR>&gt; * The background object is set to 0<BR>&gt; <BR>&gt; <BR>&gt; Then the SignedDanielssonDistanceMapImageFilter will compute<BR>&gt; the distances to the *transition* region between the 0s and<BR>&gt; the 1s.<BR>&gt; <BR>&gt; All pixesl in the 0s region will have positive distances to<BR>&gt; that boundary, while all pixels in the 1s region will have<BR>&gt; negative distances to that boundary.<BR>&gt; <BR>&gt; In your case you are feeding an input image where the *boundary*<BR>&gt; points are set to 1. Therefore, there is no "inside" to the<BR>&gt; object.<BR>&gt; <BR>&gt; E.g. if you are feeding into this distance filter an image with<BR>&gt; a thin ring, you are not going to find the "inside" of the ring.<BR>&gt; <BR>&gt; You should feed this filter with an image containing a filled<BR>&gt; circle of radius R. Where all the points at locations r &lt; R will<BR>&gt; be set to 1s. Only in that case will the distance map be able to<BR>&gt; find the "inside" of the object.<BR>&gt; <BR>&gt; <BR>&gt; Regards,<BR>&gt; <BR>&gt; <BR>&gt; Luis<BR>&gt; <BR>&gt; <BR>&gt; ---------------<BR>&gt; chensiqi wrote:<BR>&gt; &gt; Hi, Ghassan<BR>&gt; &gt; <BR>&gt; &gt; Thanks for the advice. I flip the input.<BR>&gt; &gt; The result now is both inside and outside are positive :(<BR>&gt; &gt; <BR>&gt; &gt; I use float type as the filteroutput instead of "unsigned short" in the <BR>&gt; &gt; example. I also tried unsigned short, the result is the same.<BR>&gt; &gt; <BR>&gt; &gt; Here is part of my code. <BR>&gt; &gt; ////////////////////////////////////////////////////////////////////////////////////////////////////<BR>&gt; &gt; typedef itk::Image&lt; unsigned char, 2 &gt; BinaryImageType;<BR>&gt; &gt; typedef itk::Image&lt; float , 2&gt; LSVImageType;<BR>&gt; &gt; typedef itk::SignedDanielssonDistanceMapImageFilter &lt; BinaryImageFilter, <BR>&gt; &gt; LSVImageFilter &gt; FilterType;<BR>&gt; &gt; FilterType::Pointer filter = FilterType::New();<BR>&gt; &gt; <BR>&gt; &gt; filter -&gt;SetInput ( contour ); // contour is the binary image with <BR>&gt; &gt; BinaryImageType, 1 at boundary points, and 0 elsewhere.<BR>&gt; &gt; <BR>&gt; &gt; LSVImageFilter::Pointer LSVImage = filter-&gt;GetDistanceMap();<BR>&gt; &gt; <BR>&gt; &gt; Display (LSVImage) // this is a function that displays the image.<BR>&gt; &gt; //////////////////////////////////////////////////////////////////////////////////////////////////////<BR>&gt; &gt; <BR>&gt; &gt; I notice when I cout&lt;&lt;LSV_image-&gt;GetBufferedRegion().GetSize() , the <BR>&gt; &gt; output is [0,0]. I guess there is something wrong in my code that <BR>&gt; &gt; causes this weird output size. I can display LSVImage, although both <BR>&gt; &gt; inside and outside region are postive.<BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; Thanks for any input<BR>&gt; &gt; Siqi<BR>&gt; &gt; <BR>&gt; &gt; &gt; CC: insight-users@itk.org<BR>&gt; &gt; &gt; From: hamarneh@gmail.com<BR>&gt; &gt; &gt; To: pidanchen@hotmail.com<BR>&gt; &gt; &gt; Subject: Re: [Insight-users] SignedDanielssonDistanceMapImageFilter<BR>&gt; &gt; &gt; Date: Tue, 9 Dec 2008 20:45:19 -0800<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; Hello Siqi,<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; You write: "The input is only a binary image with boundary points at<BR>&gt; &gt; &gt; 0, and all other points at 1."<BR>&gt; &gt; &gt; However, according to he documentation: "As a convention, the distance<BR>&gt; &gt; &gt; is evaluated from the boundary of the ON pixels."<BR>&gt; &gt; &gt; (from <BR>&gt; &gt; http://www.itk.org/Doxygen/html/classitk_1_1SignedDanielssonDistanceMapImageFilter.html <BR>&gt; &gt; <BR>&gt; &gt; &gt; )<BR>&gt; &gt; &gt; So, your input image should have boundary pixels set to 1 and all<BR>&gt; &gt; &gt; other points to 0 (and not the other way around).<BR>&gt; &gt; &gt; HTH,<BR>&gt; &gt; &gt; /Ghassan<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; On 9-Dec-08, at 7:24 PM, chensiqi wrote:<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; &gt;<BR>&gt; &gt; &gt; &gt; Hi, ITKers<BR>&gt; &gt; &gt; &gt;<BR>&gt; &gt; &gt; &gt; I got two ques tions regarding SignedDanielssonDistanceMapImageFilter.<BR>&gt; &gt; &gt; &gt;<BR>&gt; &gt; &gt; &gt; 1. The result I have is not "signed", both the inside and outside<BR>&gt; &gt; &gt; &gt; distance values are negative. The input is only a binary image with<BR>&gt; &gt; &gt; &gt; boundary points at 0, and all other points at 1. I was wondering<BR>&gt; &gt; &gt; &gt; how I was wondering how SignedDanielssonDistanceMapImageFilter<BR>&gt; &gt; &gt; &gt; determine the region of inside and outside.<BR>&gt; &gt; &gt; &gt;<BR>&gt; &gt; &gt; &gt; 2. In Examples of SignedDanielssonDistanceMapImageFilter. cxx, I<BR>&gt; &gt; &gt; &gt; notice that the OutputImageType of filter is unsigned short, which I<BR>&gt; &gt; &gt; &gt; don't quite understand. The output should contains both negative<BR>&gt; &gt; &gt; &gt; and positive distance, why use "unsigned" here?<BR>&gt; &gt; &gt; &gt;<BR>&gt; &gt; &gt; &gt; Thanks<BR>&gt; &gt; &gt; &gt; Siqi<BR>&gt; &gt; &gt; &gt;<BR>&gt; &gt; &gt; &gt; MSN保护盾,十八般武艺保障MSN安全! 现<BR>&gt; &gt; &gt; &gt; 在就下载! _______________________________________________<BR>&gt; &gt; &gt; &gt; Insight-users mailing list<BR>&gt; &gt; &gt; &gt; Insight-users@itk.org<BR>&gt; &gt; &gt; &gt; http://www.itk.org/mailman/listinfo/insight-users<BR>&gt; &gt; &gt;<BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; ------------------------------------------------------------------------<BR>&gt; &gt; MSN热搜榜全新升级,更多排行榜等着你! 立即查看! &lt; http://top.msn.com.cn&gt;<BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; ------------------------------------------------------------------------<BR>&gt; &gt; <BR>&gt; &gt; _______________________________________________<BR>&gt; &gt; Insight-users mailing list<BR>&gt; &gt; Insight-users@itk.org<BR>&gt; &gt; http://www.itk.org/mailman/listinfo/insight-users<BR><BR><br /><hr />使用新一代 Windows Live Messenger 轻松交流和共享! <a href='http://im.live.cn/' target='_new'>立刻下载!</a></body>
</html>