<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><br><br>Hi all,#<br>1. &nbsp; &nbsp; I can finally use my ITK320 dir installed with CMake in Xcode for an Osirix plugin.<div>2.&nbsp;&nbsp;&nbsp;&nbsp; My images are t2 3D MRI 256x256 min gray value = -21, max = 800.</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -first i just tried to segment the ventricles. The compilation takes a very long time&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;and has very little with the image information to do.</div><div>&nbsp;&nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp;- i assume is because of the sigmoid values that i set, and the 
distance map using &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FastMarchingFilter. <br>3.&nbsp;&nbsp;&nbsp; When i try to use the Chan Vese Filter the example
 from&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; http://www.itk.org/Wiki/ITK/Examples/Segmentation/MultiphaseChanAndVeseSparseFieldLevelSetSegmentation</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; by
 adding stuff to the class ActiveContours &nbsp;i can first include the 
headers and define&nbsp;&nbsp;&nbsp; that some filters for CHan Vese, but when i run it in Osirix i get 
BAD_ACCESS which means that i am using some thing that were not 
initialized properly (at least this is what i noticed so far in my 
development ). Even when i comment the new written lines it just doesn't
 change anything althought it had been working a second ago. Is this an 
Xcode bug?</div><div>4. &nbsp; &nbsp; &nbsp; I tried to create a class with a different 
name, and somehow write everything i need for Chan Vese step by step 
again, and now although i got no errors in the #include headers part, i 
got in the class when defining for ex at:<br><span class="yiv1332880698Apple-style-span" style="font-family: monospace; font-size: 10px; line-height: 12px; white-space: pre; color: rgb(0, 0, 0);"><span class="yiv1332880698kw4">typedef</span> itk<span class="yiv1332880698sy4">::</span><span class="yiv1332880698me2">ScalarChanAndVeseLevelSetFunctionData</span><span class="yiv1332880698sy1">&lt;</span> LevelSetImageType,</span></div><span class="yiv1332880698Apple-style-span" style="font-family: monospace; font-size: 10px;"><pre class="yiv1332880698de1" style="padding: 0px; border: 0px none white; color: rgb(0, 0, 0); font-family: monospace; font-style: normal; font-variant: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; margin: 0px; background-image: none; vertical-align: top;">    FeatureImageType <span class="yiv1332880698sy1">&gt;</span> DataHelperType<span class="yiv1332880698sy4">;<br></span></pre><pre
 class="yiv1332880698de1" style="padding: 0px; border: 0px none white; color: black; font: 1em/1.2em monospace; margin: 0px; background-image: none; vertical-align: top;"><span class="yiv1332880698sy4"></span><font class="yiv1332880698Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="yiv1332880698Apple-style-span" style="font-size: medium;">Error expected before token"&lt;".&nbsp;</span></font></pre><pre class="yiv1332880698de1" style="padding: 0px; border: 0px none white; color: black; font: 1em/1.2em monospace; margin: 0px; background-image: none; vertical-align: top;"> <span class="yiv1332880698Apple-style-span" style="font-family: times,serif; font-size: medium;"><br>     My problem is just that i don't see any logic in this behaviour, and i can't really reproduce<br>&nbsp;it</span><font class="yiv1332880698Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="yiv1332880698Apple-style-span"
 style="font-size: medium;"> so at least i would know that the instalation with Cmake didn't work out, or I am not <br>setting the right flags in XCode.<br>My code is:<br>- (void) ActiveContour3D:(ViewerController *)sourceV :(int)slice :(NSPoint)startingPoint :(NSString*)newname<br><br>{<br><br>typedef float InternalPixelType;<br>const unsigned int Dimension = 3; <br>typedef itk::Image&lt; InternalPixelType, Dimension &gt; InternalImageType;<br>typedef unsigned char OutputPixelType;<br>typedef itk::Image&lt; OutputPixelType, Dimension &gt; OutputImageType;<br><br>typedef itk::CastImageFilter&lt; OutputImageType, OutputImageType &gt; CastingFilterType;<br>CastingFilterType::Pointer casterfinal = CastingFilterType::New();<br><br><br>typedef itk::BinaryThresholdImageFilter&lt;InternalImageType,OutputImageType &gt; ThresholdingFilterType;<br>ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New();<br>thresholder-&gt;SetLowerThreshold(
 -1000.0 );<br>thresholder-&gt;SetUpperThreshold( 0.0 );<br>thresholder-&gt;SetOutsideValue( 0 );<br>thresholder-&gt;SetInsideValue( 255 );<br><br><br>typedef itk::GiplImageIO GiplIOType;<br>GiplIOType::Pointer giplIO = GiplIOType::New();<br>typedef itk::ImageFileWriter&lt; OutputImageType &gt; WriterType; <br>WriterType::Pointer writer = WriterType::New();<br><br>typedef itk::RescaleIntensityImageFilter&lt;InternalImageType,OutputImageType &gt; CastFilterType;<br>typedef itk::CurvatureAnisotropicDiffusionImageFilter&lt;InternalImageType,InternalImageType &gt; SmoothingFilterType;<br>SmoothingFilterType::Pointer smoothing = SmoothingFilterType::New(); <br>typedef itk::GradientMagnitudeRecursiveGaussianImageFilter&lt;InternalImageType,InternalImageType &gt; GradientFilterType;<br>typedef itk::SigmoidImageFilter&lt;InternalImageType,InternalImageType &gt; SigmoidFilterType;<br>GradientFilterType::Pointer gradientMagnitude =
 GradientFilterType::New();<br>SigmoidFilterType::Pointer sigmoid = SigmoidFilterType::New();<br><br><br>sigmoid-&gt;SetOutputMinimum( 0.0 );<br>sigmoid-&gt;SetOutputMaximum( 1.0 );<br><br><br>typedef itk::FastMarchingImageFilter&lt;InternalImageType,InternalImageType &gt; FastMarchingFilterType;<br>FastMarchingFilterType::Pointer fastMarching = FastMarchingFilterType::New();<br><br>typedef itk::GeodesicActiveContourLevelSetImageFilter&lt; InternalImageType,InternalImageType &gt; GeodesicActiveContourFilterType;<br>GeodesicActiveContourFilterType::Pointer geodesicActiveContour = GeodesicActiveContourFilterType::New();<br>const double propagationScaling = 10.0;<br>geodesicActiveContour-&gt;SetPropagationScaling(propagationScaling);<br>geodesicActiveContour-&gt;SetCurvatureScaling(1.0);<br>geodesicActiveContour-&gt;SetAdvectionScaling( 1.0 );<br>geodesicActiveContour-&gt;SetMaximumRMSError( 0.02 );<br>geodesicActiveContour-&gt;SetNumberOfIterations( 40
 );<br><br>InternalImageType::IndexType index;<br>index[0] = (long) startingPoint.x;<br>index[1] = (long) startingPoint.y;<br>index[2] = [[sourceV imageView] curImage];<br>NSLog(@"StartingPoint is %d %d %d", index[0],index[1],index[2]);<br><br><br>smoothing-&gt;SetInput([itkImage itkImporter]-&gt;GetOutput() );<br>gradientMagnitude-&gt;SetInput( smoothing-&gt;GetOutput() );<br>sigmoid-&gt;SetInput( gradientMagnitude-&gt;GetOutput() );<br>geodesicActiveContour-&gt;SetInput( fastMarching-&gt;GetOutput() );<br>geodesicActiveContour-&gt;SetFeatureImage( sigmoid-&gt;GetOutput() );<br>thresholder-&gt;SetInput( geodesicActiveContour-&gt;GetOutput() );<br>smoothing-&gt;SetTimeStep( 0.0625 );<br>smoothing-&gt;SetNumberOfIterations( 5 );<br>smoothing-&gt;SetConductanceParameter( 6.0 );<br>const double sigma =  1.0;<br>gradientMagnitude-&gt;SetSigma( sigma );<br>const double alpha = -5.0;<br>const double beta = 3.0;<br>sigmoid-&gt;SetAlpha( alpha
 );<br>sigmoid-&gt;SetBeta( beta );<br><br><br>typedef FastMarchingFilterType::NodeContainer NodeContainer;<br>typedef FastMarchingFilterType::NodeType NodeType; <br>NodeContainer::Pointer seeds = NodeContainer::New();<br>double initialDistance = 5.0;<br>double seedValue = -initialDistance;<br>NodeType node;<br>node.SetValue(seedValue);<br>node.SetIndex(index);<br>seeds-&gt;Initialize();<br>seeds-&gt;InsertElement(0,node);<br>fastMarching-&gt;SetTrialPoints(seeds);<br>fastMarching-&gt;SetSpeedConstant(1.0);<br>fastMarching-&gt;SetOutputSize([itkImage image]-&gt;GetBufferedRegion().GetSize());<br><br><br>CastFilterType::Pointer caster1 = CastFilterType::New();<br>CastFilterType::Pointer caster2 = CastFilterType::New();<br>CastFilterType::Pointer caster3 = CastFilterType::New();<br>CastFilterType::Pointer caster4 = CastFilterType::New();<br>CastFilterType::Pointer caster5 = CastFilterType::New();<br><br>WriterType::Pointer writer1 =
 WriterType::New();<br>WriterType::Pointer writer2 = WriterType::New();<br>WriterType::Pointer writer3 = WriterType::New();<br>WriterType::Pointer writer4 = WriterType::New();<br>WriterType::Pointer writer5 = WriterType::New();<br>WriterType::Pointer writerfinal = WriterType::New();<br><br>caster1-&gt;SetInput( smoothing-&gt;GetOutput() );<br>writer1-&gt;SetInput( caster1-&gt;GetOutput() );<br>char *name1 = "smoothed_dataset.gipl";<br>writer1-&gt;SetFileName(name1);<br>caster1-&gt;SetOutputMinimum( 0 );<br>caster1-&gt;SetOutputMaximum( 255 );<br>writer1-&gt;SetImageIO(giplIO);<br>try{<br>writer1-&gt;Update();<br>}<br>catch( itk::ExceptionObject &amp; excep ){<br>NSLog(@ "Exception caught at writer1!.gipl");<br>}<br>caster2-&gt;SetInput( gradientMagnitude-&gt;GetOutput() );<br>writer2-&gt;SetInput( caster2-&gt;GetOutput() );<br>char *name2 = "3DKanten.gipl";<br>writer2-&gt;SetFileName(name2);<br>caster2-&gt;SetOutputMinimum( 0
 );<br>caster2-&gt;SetOutputMaximum( 255 );<br>writer2-&gt;SetImageIO(giplIO);<br>try{<br>writer2-&gt;Update();<br>}<br>catch( itk::ExceptionObject &amp; excep ){<br>NSLog(@"Exceptionin writer2.gipl");<br>}<br>caster3-&gt;SetInput( sigmoid-&gt;GetOutput() );<br>writer3-&gt;SetInput( caster3-&gt;GetOutput() );<br>char *name3 = "inverse3DKanten.gipl";<br>writer3-&gt;SetFileName(name3);<br>caster3-&gt;SetOutputMinimum( 0 );<br>caster3-&gt;SetOutputMaximum( 255 );<br>writer3-&gt;SetImageIO(giplIO);<br>try{<br>writer3-&gt;Update();<br>}<br>catch( itk::ExceptionObject &amp; excep ){<br>NSLog(@"Exception caught at writer3 !.gipl");<br>}<br>caster4-&gt;SetInput( fastMarching-&gt;GetOutput() );<br>writer4-&gt;SetInput( caster4-&gt;GetOutput() );<br>char *name4 = "FFM.gipl";<br>writer4-&gt;SetFileName(name4);<br>caster4-&gt;SetOutputMinimum( 0 );<br>caster4-&gt;SetOutputMaximum( 255
 );<br>writer4-&gt;SetImageIO(giplIO);<br>try{<br>writer4-&gt;Update();<br>}<br>catch( itk::ExceptionObject &amp; excep ){<br>NSLog(@"Exception caught at writer4!.gipl");<br>}<br>caster5-&gt;SetInput( geodesicActiveContour-&gt;GetOutput() );<br>writer5-&gt;SetInput( caster5-&gt;GetOutput() );<br>char *name5 = "ActiveContour.gipl";<br>writer5-&gt;SetFileName(name5);<br>caster5-&gt;SetOutputMinimum( 0 );<br>caster5-&gt;SetOutputMaximum( 255 );<br>writer5-&gt;SetImageIO(giplIO);<br>try{<br>writer5-&gt;Update();<br>}<br>catch( itk::ExceptionObject &amp; excep ){<br>NSLog(@"Exception caught at writer45!.gipl");<br>}<br><br>NSLog(@"I am here already will go  further");<br><br>casterfinal-&gt;SetInput(thresholder-&gt;GetOutput());<br>writerfinal-&gt;SetInput(thresholder-&gt;GetOutput());<br>char *name6 =
 "Segmentation.gipl";<br>writerfinal-&gt;SetFileName(name6);<br>writerfinal-&gt;SetImageIO(giplIO);<br>try<br>{<br>casterfinal-&gt;Update();<br>writerfinal-&gt;Update();<br>}<br>catch( itk::ExceptionObject &amp; excep )<br>{<br>NSLog(@"Exception caught at main writer!");<br>} <br>//THIS CAUSES MY PLUGIN TO CRASH!!!!!!!<br><br>/*unsigned int nb_iteration = 10;<br>double rms = 0.02;<br>double epsilon = 1.5;<br>double curvature_weight = 1.;<br>double area_weight = 10000;<br>double volume_weight = 1.;<br>double volume = 1.;<br>double overlap_weight = 1.;<br>double l1 = 1.;<br>double l2 = 1.;<br><br>typedef itk::Image&lt; unsigned char, Dimension &gt; FeatureImageType;<br>typedef itk::ScalarChanAndVeseLevelSetFunctionData&lt; InternalImageType,FeatureImageType &gt; DataHelperType;<br>typedef itk::ConstrainedRegionBasedLevelSetFunctionSharedData&lt;InternalImageType, FeatureImageType, DataHelperType &gt; SharedDataHelperType;<br>typedef
 itk::ScalarChanAndVeseLevelSetFunction&lt; InternalImageType,FeatureImageType, SharedDataHelperType &gt; LevelSetFunctionType;<br>typedef itk::ScalarChanAndVeseSparseLevelSetImageFilter&lt; InternalImageType,FeatureImageType, OutputImageType,LevelSetFunctionType,SharedDataHelperType &gt; MultiLevelSetType;<br>typedef itk::AtanRegularizedHeavisideStepFunction&lt;float,float &gt;  DomainFunctionType;<br>DomainFunctionType::Pointer domainFunction = DomainFunctionType::New();<br>domainFunction-&gt;SetEpsilon( epsilon );*/<br><br><br>NSLog(@"I go on step and another ONEEEEEE");<br>unsigned char *buff = casterfinal-&gt;GetOutput()-&gt;GetBufferPointer();<br>if( buff)<br>{<br>.... i SHOW THE ROI IN OSIRIX<br>}<br><br><br><br>@end<br><br></span></font></pre></span><br></td></tr></table><br>