<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"> </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"> </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"> </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? Big mistake or ok?</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"> </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"> </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 <luis.ibanez@kitware.com><BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> Baoyun Li <baoyun_li123@yahoo.com><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() 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 a bug in the conversion.<BR><BR><BR><BR> Regards,<BR><BR><BR> Luis<BR><BR><BR>----------------------------------------------------------------------------------<BR>
<DIV class=gmail_quote>On Wed, Feb 25, 2009 at 4:20 PM, Baoyun Li <SPAN dir=ltr><<A href="mailto:baoyun_li123@yahoo.com" target=_blank rel=nofollow ymailto="mailto:baoyun_li123@yahoo.com">baoyun_li123@yahoo..com</A>></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> </DIV>
<DIV>I am trying to put some seed point for confidence level set segmenation. I give physical points: </DIV>
<DIV>point[0]=77; point[1]=190;point[2]=90; </DIV>
<DIV>and using TransformPhysicalPointToIndex( point, index ) to get index; my image resolution is [1.3 1.3 1.3]</DIV>
<DIV> </DIV>
<DIV>the index I got is 58 -143 67. The y index is negative.</DIV>
<DIV> </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> </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> </DIV>
<DIV> </DIV>
<DIV>Best regards and thanks a lot.</DIV>
<DIV> </DIV>
<DIV>Baoyun<BR><BR></DIV>
<DIV>Below is my template function, InputerFilter is derived from CasterImageFilter<short to float>, InternalFilter is from another CasterImageFilter<float to short int></DIV>
<DIV> </DIV>
<DIV>Basical, the image direction and resolution are all correct.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>template <unsigned int Dim,class TInputFilter, class TInternalFilter, class TScale, class TDimension></DIV>
<DIV>void GradientConfidence( TInputFilter* InputFilter, TInternalFilter* InternalFilter, TScale scale)<BR>{<BR> typedef typename TInputFilter::InputImageType OutputImageType;<BR> typedef typename TInternalFilter::InputImageType InternalImageType;<BR> typedef typename TInternalFilter::OutputImageType InputImageType;<BR> //typedef TInputFilter InputImageType;</DIV>
<DIV> typedef itk::ImageFileWriter< InternalImageType > WriterType1;<BR> typename WriterType1::Pointer writer1=WriterType1::New();<BR> typedef itk::CastImageFilter< InputImageType,InternalImageType> CastingFilterType1;<BR> typename CastingFilterType1::Pointer caster11 = CastingFilterType1::New();</DIV>
<DIV> typedef itk::CastImageFilter< InternalImageType,OutputImageType> CastingFilterType2;<BR> typename CastingFilterType1::Pointer caster21 = CastingFilterType1::New();</DIV>
<DIV> typedef itk::RecursiveGaussianImageFilter< <BR> InternalImageType,<BR> InternalImageType > GaussianFilterType;</DIV>
<DIV> typedef itk::GradientMagnitudeRecursiveGaussianImageFilter< <BR> InternalImageType, <BR> InternalImageType > GradientFilterType;</DIV>
<DIV> typename GradientFilterType::Pointer gradientMagnitude = GradientFilterType::New();<BR> <BR> const double sigma =(float)1.0;<BR> // gradientMagnitude-SetSpacing( InputFilter->GetOutput()->GetSpacing() );<BR> <BR> gradientMagnitude->SetSigma( sigma );<BR> gradientMagnitude->SetInput(InputFilter->GetOutput());<BR> <BR> writer1->SetFileName("../data/gradient.hdr");<BR> writer1->SetInput(gradientMagnitude->GetOutput());<BR> InternalFilter->SetInput(gradientMagnitude->GetOutput());<BR> gradientMagnitude->Update();</DIV>
<DIV><BR>//to set seed points<BR> </DIV>
<DIV> typedef itk::Point< double, InternalImageType::ImageDimension > InternalPointType;<BR> InternalPointType point;<BR> point[0]=77; point[1]=190;point[2]=90;<BR> typedef itk::Index< InternalImageType::ImageDimension > IndexType;<BR> IndexType index;<BR> gradientMagnitude->GetOutput()->TransformPhysicalPointToIndex( point, index );<BR> std::cout << "index" << index << std::endl;<BR> std::cout << "gradient image spacing"<<gradientMagnitude->GetOutput()->GetSpacing() << std::endl;<BR> std::cout << "function input spacing"<<InputFilter->GetOutput()->GetSpacing() << std::endl;<BR> std::cout << "gradient image direction"<<gradientMagnitude->GetOutput()->GetDirection() << std::endl;<BR> std::cout << "function input
direction"<<InputFilter->GetOutput()->GetDirection() << std::endl;</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> <BR>// <BR>// // InternalFilter->SetInput(InputFilter->GetOutput());<BR>// <BR> try<BR> {<BR> writer1->Update();<BR> }<BR> catch( itk::ExceptionObject & excep )<BR> {<BR> std::cerr << "Exception caught !" << std::endl;<BR> std::cerr << excep << std::endl;<BR> }</DIV>
<DIV>std::cout << InternalFilter->GetOutput()->GetSpacing() << std::endl;<BR> <BR> <BR> <BR> <BR> <BR>};</DIV>
<DIV> </DIV>
<DIV>#endif</DIV></DIV><BR></DIV></BLOCKQUOTE></DIV><BR></DIV></div><br>
</body></html>