<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial">Hi ,everyone&nbsp;<div>&nbsp; &nbsp; &nbsp;Using the code which included in folder Example/Segmentation , GeodesicActiveContourImageFilter , I can segment a jpg format picture . But if I want to segment a dicom file , a error happen . Please help me ! &nbsp;My code is shown as follow .&nbsp;</div><div>&nbsp; &nbsp; Thank you in advance !</div><div>zhq</div><div><br></div><div><div>#include "itkGeodesicActiveContourLevelSetImageFilter.h"</div><div>#include "itkCurvatureAnisotropicDiffusionImageFilter.h"</div><div>#include "itkGradientMagnitudeRecursiveGaussianImageFilter.h"</div><div>#include "itkSigmoidImageFilter.h"</div><div>#include "itkFastMarchingImageFilter.h"</div><div>#include "itkRescaleIntensityImageFilter.h"</div><div>#include "itkBinaryThresholdImageFilter.h"</div><div>#include "itkImageFileReader.h"</div><div>#include "itkImageFileWriter.h"</div><div>#include "itkGDCMImageIO.h"</div><div>#include "itkJPEGImageIO.h"</div><div><br></div><div>int main()</div><div>{</div><div>&nbsp; typedef &nbsp; float &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; InternalPixelType;</div><div>&nbsp; const &nbsp; &nbsp; unsigned int &nbsp; &nbsp;Dimension = 2;</div><div>&nbsp; typedef itk::Image&lt; InternalPixelType, Dimension &gt; &nbsp;InternalImageType;</div><div><br></div><div>&nbsp; typedef unsigned char &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;OutputPixelType;</div><div>&nbsp; typedef itk::Image&lt; OutputPixelType, Dimension &gt; OutputImageType;</div><div>&nbsp; typedef itk::BinaryThresholdImageFilter&lt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; InternalImageType,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OutputImageType &nbsp; &nbsp;&gt; &nbsp; &nbsp; &nbsp; ThresholdingFilterType;</div><div><br></div><div>&nbsp; ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New();</div><div><br></div><div>&nbsp; thresholder-&gt;SetLowerThreshold( -1000.0 );</div><div>&nbsp; thresholder-&gt;SetUpperThreshold( &nbsp; &nbsp; 0 );</div><div><br></div><div>&nbsp; thresholder-&gt;SetOutsideValue( &nbsp;0 &nbsp;);</div><div>&nbsp; thresholder-&gt;SetInsideValue( &nbsp;255 );</div><div>// &nbsp;************* &nbsp;reader &nbsp; ****************************** &nbsp;//</div><div><br></div><div>&nbsp; typedef &nbsp;itk::ImageFileReader&lt; InternalImageType &gt; ReaderType;</div><div>&nbsp; ReaderType::Pointer reader = ReaderType::New();</div><div>// &nbsp;reader-&gt;SetFileName("C:\\Users\\zhq\\Desktop\\BrainProtonDensitySlice.png");</div><div><br></div><div>&nbsp; reader-&gt;SetImageIO(itk::GDCMImageIO::New());</div><div>&nbsp; reader-&gt;SetFileName("C:\\Users\\zhq\\Desktop\\data\\SNAP_CR\\E403434298\\E403434298S1901I301.dcm");&nbsp;</div><div>&nbsp;&nbsp;</div><div><br></div><div>// &nbsp;reader-&gt;SetImageIO(itk::JPEGImageIO::New());</div><div>// &nbsp;reader-&gt;SetFileName("C:\\Users\\zhq\\Desktop\\data\\picture8\\1.jpeg");</div><div>&nbsp;&nbsp;</div><div>&nbsp; reader-&gt;Update();</div><div>&nbsp; std::cout&lt;&lt;"reader update"&lt;&lt;std::endl;</div><div>// ************* &nbsp;finish reader &nbsp;********************** &nbsp; &nbsp;//&nbsp;</div><div><br></div><div><br></div><div>// ************* &nbsp;writer &nbsp;******************************* &nbsp;//&nbsp;</div><div>&nbsp; typedef &nbsp;itk::ImageFileWriter&lt; &nbsp;OutputImageType &nbsp;&gt; WriterType;</div><div>&nbsp; WriterType::Pointer writer = WriterType::New();</div><div>&nbsp; writer-&gt;SetFileName("C:\\Users\\zhq\\Desktop\\ActiveContour.png");</div><div><br></div><div><br></div><div>// ************* &nbsp;finish &nbsp;writer &nbsp; ********************** //</div><div><br></div><div>&nbsp; typedef itk::RescaleIntensityImageFilter&lt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;InternalImageType,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;OutputImageType &gt; &nbsp; CastFilterType;</div><div><br></div><div>&nbsp; typedef &nbsp; itk::GradientMagnitudeRecursiveGaussianImageFilter&lt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;InternalImageType,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;InternalImageType &gt; &nbsp;GradientFilterType;</div><div>&nbsp; typedef &nbsp; itk::SigmoidImageFilter&lt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;InternalImageType,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;InternalImageType &gt; &nbsp;SigmoidFilterType;</div><div><br></div><div>&nbsp; GradientFilterType::Pointer &nbsp;gradientMagnitude = GradientFilterType::New();</div><div><br></div><div>&nbsp; SigmoidFilterType::Pointer sigmoid = SigmoidFilterType::New();</div><div><br></div><div>&nbsp; sigmoid-&gt;SetOutputMinimum( &nbsp;0.0 &nbsp;);</div><div>&nbsp; sigmoid-&gt;SetOutputMaximum( &nbsp;1.0 &nbsp;);</div><div><br></div><div>&nbsp; typedef &nbsp;itk::FastMarchingImageFilter&lt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; InternalImageType,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; InternalImageType &gt; &nbsp; &nbsp;FastMarchingFilterType;</div><div><br></div><div>&nbsp; FastMarchingFilterType::Pointer &nbsp;fastMarching = FastMarchingFilterType::New();</div><div><br></div><div>&nbsp; typedef &nbsp;itk::GeodesicActiveContourLevelSetImageFilter&lt; InternalImageType,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; InternalImageType &gt; &nbsp; &nbsp;GeodesicActiveContourFilterType;</div><div>&nbsp; GeodesicActiveContourFilterType::Pointer geodesicActiveContour =</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GeodesicActiveContourFilterType::New();</div><div>// &nbsp;geodesicActiveContour-&gt;Update();</div><div>// &nbsp;std::cout&lt;&lt;"geodesicActiveContour new updata"&lt;&lt;std::endl;</div><div><br></div><div>&nbsp; const double propagationScaling = 0.4;</div><div><br></div><div>&nbsp; geodesicActiveContour-&gt;SetPropagationScaling( propagationScaling );</div><div>// &nbsp;geodesicActiveContour-&gt;Update();</div><div>// &nbsp;std::cout&lt;&lt;"geodesicActiveContour SetPropagationScaling updata"&lt;&lt;std::endl;</div><div>&nbsp; geodesicActiveContour-&gt;SetCurvatureScaling( 1.0 );</div><div>&nbsp; geodesicActiveContour-&gt;SetAdvectionScaling( 1.0 );</div><div>// &nbsp;geodesicActiveContour-&gt;Update();</div><div>// &nbsp;std::cout&lt;&lt;"geodesicActiveContour SetAdvectionScaling updata"&lt;&lt;std::endl;</div><div><br></div><div>&nbsp; geodesicActiveContour-&gt;SetMaximumRMSError( 0.02 );</div><div>&nbsp; geodesicActiveContour-&gt;SetNumberOfIterations( 800 );</div><div>// &nbsp;geodesicActiveContour-&gt;Update();</div><div>// &nbsp;std::cout&lt;&lt;"geodesicActiveContour SetNumberOfIterations updata"&lt;&lt;std::endl;</div><div><br></div><div>&nbsp; gradientMagnitude-&gt;SetInput( reader-&gt;GetOutput() );</div><div>&nbsp; sigmoid-&gt;SetInput( gradientMagnitude-&gt;GetOutput() );</div><div><br></div><div>&nbsp; geodesicActiveContour-&gt;SetInput( &nbsp;fastMarching-&gt;GetOutput() );</div><div>&nbsp; geodesicActiveContour-&gt;SetFeatureImage( sigmoid-&gt;GetOutput() );</div><div>// &nbsp;geodesicActiveContour-&gt;Update();</div><div>// &nbsp;std::cout&lt;&lt;"geodesicActiveContour SetFeatureImage updata"&lt;&lt;std::endl;</div><div><br></div><div>&nbsp; thresholder-&gt;SetInput( geodesicActiveContour-&gt;GetOutput() );</div><div>&nbsp; writer-&gt;SetInput( thresholder-&gt;GetOutput() );</div><div><br></div><div>&nbsp; const double sigma = 0.4 ;</div><div>&nbsp; gradientMagnitude-&gt;SetSigma( &nbsp;sigma &nbsp;);</div><div><br></div><div>&nbsp; const double alpha = &nbsp;-0.2;</div><div>&nbsp; const double beta &nbsp;= &nbsp;10;</div><div><br></div><div>&nbsp; sigmoid-&gt;SetAlpha( alpha );</div><div>&nbsp; sigmoid-&gt;SetBeta( &nbsp;beta &nbsp;);</div><div><br></div><div>&nbsp; typedef FastMarchingFilterType::NodeContainer &nbsp;NodeContainer;</div><div>&nbsp; typedef FastMarchingFilterType::NodeType &nbsp; &nbsp; &nbsp; NodeType;</div><div><br></div><div>&nbsp; NodeContainer::Pointer seeds = NodeContainer::New();</div><div><br></div><div>&nbsp; InternalImageType::IndexType &nbsp;seedPosition;</div><div><br></div><div>&nbsp; seedPosition[0] = 370 ; // 81;</div><div>&nbsp; seedPosition[1] = 443 ; // 114;</div><div><br></div><div>&nbsp; const double initialDistance = 5;</div><div><br></div><div>&nbsp; NodeType node;</div><div><br></div><div>&nbsp; const double seedValue = - initialDistance;</div><div><br></div><div>&nbsp; node.SetValue( seedValue );</div><div>&nbsp; node.SetIndex( seedPosition );</div><div><br></div><div>&nbsp; seeds-&gt;Initialize();</div><div>&nbsp; seeds-&gt;InsertElement( 0, node );</div><div><br></div><div>&nbsp; fastMarching-&gt;SetTrialPoints( &nbsp;seeds &nbsp;);</div><div><br></div><div>&nbsp; fastMarching-&gt;SetSpeedConstant( 1.0 );</div><div><br></div><div>&nbsp; fastMarching-&gt;SetOutputSize(</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;reader-&gt;GetOutput()-&gt;GetBufferedRegion().GetSize() );</div><div><br></div><div><br></div><div>&nbsp;&nbsp;</div><div>&nbsp; gradientMagnitude-&gt;Update();</div><div>&nbsp; std::cout&lt;&lt;"gradientMagnitude update"&lt;&lt;std::endl;</div><div><br></div><div>&nbsp; sigmoid-&gt;Update();</div><div>&nbsp; std::cout&lt;&lt;"sigmoid update"&lt;&lt;std::endl;</div><div><br></div><div>&nbsp; fastMarching-&gt;Update();</div><div>&nbsp; std::cout&lt;&lt;"fastMarching update"&lt;&lt;std::endl;</div><div><br></div><div>&nbsp; geodesicActiveContour-&gt;Update();</div><div>&nbsp; std::cout&lt;&lt;"geodesicActiveContour update"&lt;&lt;std::endl;</div><div><br></div><div>&nbsp; writer-&gt;Update();</div><div>&nbsp; std::cout&lt;&lt;"writer update"&lt;&lt;std::endl;</div><div><br></div><div><br></div><div><br></div><div>&nbsp; std::cout &lt;&lt; std::endl;</div><div>&nbsp; std::cout &lt;&lt; "Max. no. iterations: " &lt;&lt; geodesicActiveContour-&gt;GetNumberOfIterations() &lt;&lt; std::endl;</div><div>&nbsp; std::cout &lt;&lt; "Max. RMS error: " &lt;&lt; geodesicActiveContour-&gt;GetMaximumRMSError() &lt;&lt; std::endl;</div><div>&nbsp; std::cout &lt;&lt; std::endl;</div><div>&nbsp; std::cout &lt;&lt; "No. elpased iterations: " &lt;&lt; geodesicActiveContour-&gt;GetElapsedIterations() &lt;&lt; std::endl;</div><div>&nbsp; std::cout &lt;&lt; "RMS change: " &lt;&lt; geodesicActiveContour-&gt;GetRMSChange() &lt;&lt; std::endl;</div><div><br></div><div>&nbsp; return 0;</div><div>}</div></div><div><br></div></div>