<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><br><br>Hi all,#<br>1. I can finally use my ITK320 dir installed with CMake in Xcode for an Osirix plugin.<div>2. My images are t2 3D MRI 256x256 min gray value = -21, max = 800.</div><div> -first i just tried to segment the ventricles. The compilation takes a very long time </div><div> and has very little with the image information to do.</div><div>
- i assume is because of the sigmoid values that i set, and the
distance map using FastMarchingFilter. <br>3. When i try to use the Chan Vese Filter the example
from </div><div> http://www.itk.org/Wiki/ITK/Examples/Segmentation/MultiphaseChanAndVeseSparseFieldLevelSetSegmentation</div><div> by
adding stuff to the class ActiveContours i can first include the
headers and define 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. 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"><</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">></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"<". </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> 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< InternalPixelType, Dimension > InternalImageType;<br>typedef unsigned char OutputPixelType;<br>typedef itk::Image< OutputPixelType, Dimension > OutputImageType;<br><br>typedef itk::CastImageFilter< OutputImageType, OutputImageType > CastingFilterType;<br>CastingFilterType::Pointer casterfinal = CastingFilterType::New();<br><br><br>typedef itk::BinaryThresholdImageFilter<InternalImageType,OutputImageType > ThresholdingFilterType;<br>ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New();<br>thresholder->SetLowerThreshold(
-1000.0 );<br>thresholder->SetUpperThreshold( 0.0 );<br>thresholder->SetOutsideValue( 0 );<br>thresholder->SetInsideValue( 255 );<br><br><br>typedef itk::GiplImageIO GiplIOType;<br>GiplIOType::Pointer giplIO = GiplIOType::New();<br>typedef itk::ImageFileWriter< OutputImageType > WriterType; <br>WriterType::Pointer writer = WriterType::New();<br><br>typedef itk::RescaleIntensityImageFilter<InternalImageType,OutputImageType > CastFilterType;<br>typedef itk::CurvatureAnisotropicDiffusionImageFilter<InternalImageType,InternalImageType > SmoothingFilterType;<br>SmoothingFilterType::Pointer smoothing = SmoothingFilterType::New(); <br>typedef itk::GradientMagnitudeRecursiveGaussianImageFilter<InternalImageType,InternalImageType > GradientFilterType;<br>typedef itk::SigmoidImageFilter<InternalImageType,InternalImageType > SigmoidFilterType;<br>GradientFilterType::Pointer gradientMagnitude =
GradientFilterType::New();<br>SigmoidFilterType::Pointer sigmoid = SigmoidFilterType::New();<br><br><br>sigmoid->SetOutputMinimum( 0.0 );<br>sigmoid->SetOutputMaximum( 1.0 );<br><br><br>typedef itk::FastMarchingImageFilter<InternalImageType,InternalImageType > FastMarchingFilterType;<br>FastMarchingFilterType::Pointer fastMarching = FastMarchingFilterType::New();<br><br>typedef itk::GeodesicActiveContourLevelSetImageFilter< InternalImageType,InternalImageType > GeodesicActiveContourFilterType;<br>GeodesicActiveContourFilterType::Pointer geodesicActiveContour = GeodesicActiveContourFilterType::New();<br>const double propagationScaling = 10.0;<br>geodesicActiveContour->SetPropagationScaling(propagationScaling);<br>geodesicActiveContour->SetCurvatureScaling(1.0);<br>geodesicActiveContour->SetAdvectionScaling( 1.0 );<br>geodesicActiveContour->SetMaximumRMSError( 0.02 );<br>geodesicActiveContour->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->SetInput([itkImage itkImporter]->GetOutput() );<br>gradientMagnitude->SetInput( smoothing->GetOutput() );<br>sigmoid->SetInput( gradientMagnitude->GetOutput() );<br>geodesicActiveContour->SetInput( fastMarching->GetOutput() );<br>geodesicActiveContour->SetFeatureImage( sigmoid->GetOutput() );<br>thresholder->SetInput( geodesicActiveContour->GetOutput() );<br>smoothing->SetTimeStep( 0.0625 );<br>smoothing->SetNumberOfIterations( 5 );<br>smoothing->SetConductanceParameter( 6.0 );<br>const double sigma = 1.0;<br>gradientMagnitude->SetSigma( sigma );<br>const double alpha = -5.0;<br>const double beta = 3.0;<br>sigmoid->SetAlpha( alpha
);<br>sigmoid->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->Initialize();<br>seeds->InsertElement(0,node);<br>fastMarching->SetTrialPoints(seeds);<br>fastMarching->SetSpeedConstant(1.0);<br>fastMarching->SetOutputSize([itkImage image]->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->SetInput( smoothing->GetOutput() );<br>writer1->SetInput( caster1->GetOutput() );<br>char *name1 = "smoothed_dataset.gipl";<br>writer1->SetFileName(name1);<br>caster1->SetOutputMinimum( 0 );<br>caster1->SetOutputMaximum( 255 );<br>writer1->SetImageIO(giplIO);<br>try{<br>writer1->Update();<br>}<br>catch( itk::ExceptionObject & excep ){<br>NSLog(@ "Exception caught at writer1!.gipl");<br>}<br>caster2->SetInput( gradientMagnitude->GetOutput() );<br>writer2->SetInput( caster2->GetOutput() );<br>char *name2 = "3DKanten.gipl";<br>writer2->SetFileName(name2);<br>caster2->SetOutputMinimum( 0
);<br>caster2->SetOutputMaximum( 255 );<br>writer2->SetImageIO(giplIO);<br>try{<br>writer2->Update();<br>}<br>catch( itk::ExceptionObject & excep ){<br>NSLog(@"Exceptionin writer2.gipl");<br>}<br>caster3->SetInput( sigmoid->GetOutput() );<br>writer3->SetInput( caster3->GetOutput() );<br>char *name3 = "inverse3DKanten.gipl";<br>writer3->SetFileName(name3);<br>caster3->SetOutputMinimum( 0 );<br>caster3->SetOutputMaximum( 255 );<br>writer3->SetImageIO(giplIO);<br>try{<br>writer3->Update();<br>}<br>catch( itk::ExceptionObject & excep ){<br>NSLog(@"Exception caught at writer3 !.gipl");<br>}<br>caster4->SetInput( fastMarching->GetOutput() );<br>writer4->SetInput( caster4->GetOutput() );<br>char *name4 = "FFM.gipl";<br>writer4->SetFileName(name4);<br>caster4->SetOutputMinimum( 0 );<br>caster4->SetOutputMaximum( 255
);<br>writer4->SetImageIO(giplIO);<br>try{<br>writer4->Update();<br>}<br>catch( itk::ExceptionObject & excep ){<br>NSLog(@"Exception caught at writer4!.gipl");<br>}<br>caster5->SetInput( geodesicActiveContour->GetOutput() );<br>writer5->SetInput( caster5->GetOutput() );<br>char *name5 = "ActiveContour.gipl";<br>writer5->SetFileName(name5);<br>caster5->SetOutputMinimum( 0 );<br>caster5->SetOutputMaximum( 255 );<br>writer5->SetImageIO(giplIO);<br>try{<br>writer5->Update();<br>}<br>catch( itk::ExceptionObject & excep ){<br>NSLog(@"Exception caught at writer45!.gipl");<br>}<br><br>NSLog(@"I am here already will go further");<br><br>casterfinal->SetInput(thresholder->GetOutput());<br>writerfinal->SetInput(thresholder->GetOutput());<br>char *name6 =
"Segmentation.gipl";<br>writerfinal->SetFileName(name6);<br>writerfinal->SetImageIO(giplIO);<br>try<br>{<br>casterfinal->Update();<br>writerfinal->Update();<br>}<br>catch( itk::ExceptionObject & 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< unsigned char, Dimension > FeatureImageType;<br>typedef itk::ScalarChanAndVeseLevelSetFunctionData< InternalImageType,FeatureImageType > DataHelperType;<br>typedef itk::ConstrainedRegionBasedLevelSetFunctionSharedData<InternalImageType, FeatureImageType, DataHelperType > SharedDataHelperType;<br>typedef
itk::ScalarChanAndVeseLevelSetFunction< InternalImageType,FeatureImageType, SharedDataHelperType > LevelSetFunctionType;<br>typedef itk::ScalarChanAndVeseSparseLevelSetImageFilter< InternalImageType,FeatureImageType, OutputImageType,LevelSetFunctionType,SharedDataHelperType > MultiLevelSetType;<br>typedef itk::AtanRegularizedHeavisideStepFunction<float,float > DomainFunctionType;<br>DomainFunctionType::Pointer domainFunction = DomainFunctionType::New();<br>domainFunction->SetEpsilon( epsilon );*/<br><br><br>NSLog(@"I go on step and another ONEEEEEE");<br>unsigned char *buff = casterfinal->GetOutput()->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>