<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><DIV><BR></DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">Luis:</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp;</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">Thanks.</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp;</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">Can I put negative index as the seed points for region growing algorithm?</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp;</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">What I did now it is to force the negtive index to be positive?&nbsp; Big mistake or ok?</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp;</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">Thanks</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp;</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">Baoyun<BR></DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"><FONT face=Tahoma size=2>
<HR SIZE=1>
<B><SPAN style="FONT-WEIGHT: bold">From:</SPAN></B> Luis Ibanez &lt;luis.ibanez@kitware.com&gt;<BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> Baoyun Li &lt;baoyun_li123@yahoo.com&gt;<BR><B><SPAN style="FONT-WEIGHT: bold">Cc:</SPAN></B> insight-users@itk.org<BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> Wednesday, February 25, 2009 4:00:21 PM<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> Re: get negative index by----TransformPhysicalPointToIndex<BR></FONT><BR><BR>Hi Baoyn,<BR><BR>It is perfectly valid to get Indices with negative components when<BR>using TransformPhysicalPointToIndex().<BR><BR>It is *your* responsibility to test for the indices to be inside of the<BR>image before you use them to access data..<BR><BR>This can be done with <BR><BR>the IsInside() method of the ImageRegion class, and/or with <BR>the IsInsideBuffer()&nbsp; method of the Interpolators.<BR><BR><BR>This being said,<BR>It is not a bad idea to double
 check your computation, to<BR>make sure that there is not&nbsp; a bug in the conversion.<BR><BR><BR><BR>&nbsp;&nbsp;&nbsp; Regards,<BR><BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Luis<BR><BR><BR>----------------------------------------------------------------------------------<BR>
<DIV class=gmail_quote>On Wed, Feb 25, 2009 at 4:20 PM, Baoyun Li <SPAN dir=ltr>&lt;<A href="mailto:baoyun_li123@yahoo.com" target=_blank rel=nofollow ymailto="mailto:baoyun_li123@yahoo.com">baoyun_li123@yahoo..com</A>&gt;</SPAN> wrote:<BR>
<BLOCKQUOTE class=gmail_quote style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">
<DIV>Dear Luis and All:</DIV>
<DIV>&nbsp;</DIV>
<DIV>I am trying to put some seed point for confidence level set segmenation. I give physical points:&nbsp;</DIV>
<DIV>point[0]=77; point[1]=190;point[2]=90; </DIV>
<DIV>and using&nbsp; TransformPhysicalPointToIndex( point, index ) to get index; my image resolution is&nbsp; [1.3 1.3 1.3]</DIV>
<DIV>&nbsp;</DIV>
<DIV>the index I got is 58 -143 67. The y index is negative.</DIV>
<DIV>&nbsp;</DIV>
<DIV>I checked the image direction in my template function, it is 1 0 0; 0 -1 0; 0 0 1. The direction is consistent with the image I read in the main program, and the resolution of the image is also correct</DIV>
<DIV>&nbsp;</DIV>
<DIV>It is clear 0 -1 0 of y axis direction cosine gives me the negative index. Can somebody teach me to solve this problem?</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Best regards and thanks&nbsp; a lot.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Baoyun<BR><BR></DIV>
<DIV>Below is my template function,&nbsp; InputerFilter is derived from CasterImageFilter&lt;short to float&gt;, InternalFilter is from another CasterImageFilter&lt;float to short int&gt;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Basical, the image direction and resolution are all correct.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>template &lt;unsigned int Dim,class TInputFilter, class TInternalFilter, class TScale, class TDimension&gt;</DIV>
<DIV>void GradientConfidence( TInputFilter* InputFilter, TInternalFilter* InternalFilter, TScale scale)<BR>{<BR>&nbsp;&nbsp;&nbsp; typedef typename TInputFilter::InputImageType OutputImageType;<BR>&nbsp; typedef typename TInternalFilter::InputImageType InternalImageType;<BR>&nbsp; typedef typename TInternalFilter::OutputImageType InputImageType;<BR>&nbsp;&nbsp; //typedef&nbsp; TInputFilter InputImageType;</DIV>
<DIV>&nbsp; typedef itk::ImageFileWriter&lt; InternalImageType &gt;&nbsp; WriterType1;<BR>&nbsp; typename WriterType1::Pointer writer1=WriterType1::New();<BR>&nbsp; typedef&nbsp; itk::CastImageFilter&lt; InputImageType,InternalImageType&gt; CastingFilterType1;<BR>&nbsp; typename CastingFilterType1::Pointer caster11 = CastingFilterType1::New();</DIV>
<DIV>&nbsp; typedef itk::CastImageFilter&lt; InternalImageType,OutputImageType&gt; CastingFilterType2;<BR>&nbsp; typename CastingFilterType1::Pointer caster21 = CastingFilterType1::New();</DIV>
<DIV>&nbsp; typedef itk::RecursiveGaussianImageFilter&lt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InternalImageType,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InternalImageType &gt; GaussianFilterType;</DIV>
<DIV>&nbsp;&nbsp; typedef&nbsp;&nbsp; itk::GradientMagnitudeRecursiveGaussianImageFilter&lt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InternalImageType, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InternalImageType &gt;&nbsp; GradientFilterType;</DIV>
<DIV>&nbsp; typename GradientFilterType::Pointer&nbsp; gradientMagnitude = GradientFilterType::New();<BR>&nbsp; <BR>&nbsp;&nbsp; const double sigma =(float)1.0;<BR>&nbsp; // gradientMagnitude-SetSpacing( InputFilter-&gt;GetOutput()-&gt;GetSpacing() );<BR>&nbsp; <BR>&nbsp;&nbsp; gradientMagnitude-&gt;SetSigma(&nbsp; sigma&nbsp; );<BR>&nbsp;&nbsp; gradientMagnitude-&gt;SetInput(InputFilter-&gt;GetOutput());<BR>&nbsp; <BR>&nbsp;&nbsp; writer1-&gt;SetFileName("../data/gradient.hdr");<BR>&nbsp;&nbsp; writer1-&gt;SetInput(gradientMagnitude-&gt;GetOutput());<BR>&nbsp;&nbsp; InternalFilter-&gt;SetInput(gradientMagnitude-&gt;GetOutput());<BR>&nbsp;&nbsp; gradientMagnitude-&gt;Update();</DIV>
<DIV><BR>//to set seed points<BR>&nbsp;</DIV>
<DIV>&nbsp;&nbsp; typedef itk::Point&lt; double, InternalImageType::ImageDimension &gt; InternalPointType;<BR>&nbsp;&nbsp; InternalPointType point;<BR>&nbsp;&nbsp; point[0]=77; point[1]=190;point[2]=90;<BR>&nbsp;&nbsp; typedef itk::Index&lt; InternalImageType::ImageDimension &gt; IndexType;<BR>&nbsp;&nbsp; IndexType index;<BR>&nbsp;&nbsp; gradientMagnitude-&gt;GetOutput()-&gt;TransformPhysicalPointToIndex( point, index );<BR>&nbsp;&nbsp; std::cout &lt;&lt; "index" &lt;&lt; index &lt;&lt; std::endl;<BR>&nbsp;&nbsp; std::cout &lt;&lt; "gradient image spacing"&lt;&lt;gradientMagnitude-&gt;GetOutput()-&gt;GetSpacing() &lt;&lt; std::endl;<BR>&nbsp;&nbsp; std::cout &lt;&lt; "function input spacing"&lt;&lt;InputFilter-&gt;GetOutput()-&gt;GetSpacing() &lt;&lt; std::endl;<BR>&nbsp;&nbsp; std::cout &lt;&lt; "gradient image direction"&lt;&lt;gradientMagnitude-&gt;GetOutput()-&gt;GetDirection() &lt;&lt; std::endl;<BR>&nbsp;&nbsp; std::cout &lt;&lt; "function input
 direction"&lt;&lt;InputFilter-&gt;GetOutput()-&gt;GetDirection() &lt;&lt; std::endl;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp; <BR>// <BR>//&nbsp; // InternalFilter-&gt;SetInput(InputFilter-&gt;GetOutput());<BR>//&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; try<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writer1-&gt;Update();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp; catch( itk::ExceptionObject &amp; excep )<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "Exception caught !" &lt;&lt; std::endl;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; excep &lt;&lt; std::endl;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>std::cout &lt;&lt; InternalFilter-&gt;GetOutput()-&gt;GetSpacing() &lt;&lt; std::endl;<BR>&nbsp;<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp; <BR>&nbsp; <BR>&nbsp; <BR>};</DIV>
<DIV>&nbsp;</DIV>
<DIV>#endif</DIV></DIV><BR></DIV></BLOCKQUOTE></DIV><BR></DIV></div><br>

      </body></html>