<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt">Hi all,<br><br>&nbsp; I have modified the original Otsu segmentation with multiple thresholds code available here :<br><br>http://www.vtk.org/Wiki/ITK/Examples/WishList/Segmentation/OtsuMultipleThresholdsCalculator<br><br>to work on Unsigned short image type.&nbsp; The program builds and executes fine in Release mode till it crashes at Filter-&gt;Update(). <br><br>In debug mode I get a compile error :<br><br>error C2660: 'itk::LightObject::operator new' : function does not take 4 arguments&nbsp; for <br>ScalarImageToHistogramGenerator<br><br><br>How can I fix this ? I am using itk 3.20. My declarations are as follows:<br><br>where ImageType = &lt;unsigned short, 2&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UCharImageType = &lt;unsigned char, 2&gt;<br><br><br>//code snippet<br>typedef
 itk::Statistics::ScalarImageToHistogramGenerator&lt;ImageType &gt;&nbsp; ScalarImageToHistogramGeneratorType;<br>&nbsp;&nbsp;&nbsp; typedef&nbsp; itk::OtsuMultipleThresholdsCalculator&lt;ScalarImageToHistogramGeneratorType::HistogramType&nbsp; &gt; CalculatorType;<br>&nbsp;&nbsp;&nbsp; typedef itk::BinaryThresholdImageFilter&lt; ImageType, UCharImageType &gt;&nbsp; FilterType;<br>&nbsp;&nbsp;&nbsp; typedef itk::AddImageFilter&lt; UCharImageType, ImageType ,ImageType&gt;&nbsp; AddFilterType;<br><br>&nbsp;&nbsp;&nbsp; ScalarImageToHistogramGeneratorType::Pointer scalarImageToHistogramGenerator =&nbsp;&nbsp;&nbsp; ScalarImageToHistogramGeneratorType::New();<br>&nbsp;&nbsp;&nbsp; CalculatorType::Pointer calculator = CalculatorType::New();<br>&nbsp;&nbsp;&nbsp; FilterType::Pointer filter = FilterType::New();<br>&nbsp;&nbsp;&nbsp; AddFilterType::Pointer addFilter = AddFilterType::New();<br><br><br>&nbsp;&nbsp;&nbsp; int num_of_bins =
 128;<br>&nbsp;&nbsp;&nbsp; int num_thresholds = 2;<br>&nbsp;&nbsp;&nbsp; scalarImageToHistogramGenerator-&gt;SetNumberOfBins( num_of_bins );<br>&nbsp;&nbsp;&nbsp; calculator-&gt;SetNumberOfThresholds(num_thresholds);<br>&nbsp;&nbsp;&nbsp; scalarImageToHistogramGenerator-&gt;SetInput(mpImage);<br>&nbsp;&nbsp;&nbsp; scalarImageToHistogramGenerator-&gt;Compute();<br>&nbsp;&nbsp;&nbsp; calculator-&gt;SetInputHistogram(scalarImageToHistogramGenerator-&gt;GetOutput());<br>&nbsp;&nbsp;&nbsp; filter-&gt;SetInput(mpImage );<br><br>&nbsp;&nbsp;&nbsp; calculator-&gt;Update();<br><br>&nbsp;&nbsp;&nbsp; const CalculatorType::OutputType &amp;thresholdVector =&nbsp; calculator-&gt;GetOutput();<br>&nbsp;&nbsp;&nbsp; CalculatorType::OutputType::const_iterator itNum =&nbsp; thresholdVector.begin();<br><br>&nbsp;&nbsp;&nbsp; PixelType min = 0;<br>&nbsp;&nbsp;&nbsp; PixelType max = 255;<br><br>&nbsp;&nbsp;&nbsp; const PixelType outsideValue = 0;<br><br>&nbsp;&nbsp;&nbsp;
 //std::string outputFileBase = argv[2];<br>&nbsp;&nbsp;&nbsp; //std::string outputFile;<br>&nbsp;&nbsp;&nbsp; //std::string format = argv[2];<br><br>&nbsp;&nbsp;&nbsp; //char outputFilename[1000];<br>&nbsp;&nbsp;&nbsp; //outputFile = outputFileBase;<br>&nbsp;&nbsp;&nbsp; //outputFile += argv[3];&nbsp;&nbsp; // filename extension<br><br>&nbsp;&nbsp;&nbsp; PixelType lowerThreshold = min;<br>&nbsp;&nbsp;&nbsp; PixelType upperThreshold;<br><br>&nbsp;&nbsp;&nbsp; filter-&gt;SetOutsideValue(outsideValue );<br>&nbsp;&nbsp;&nbsp; PixelType step =(255/(num_thresholds+1) );<br>&nbsp;&nbsp;&nbsp; PixelType count=step;<br><br>&nbsp;&nbsp;&nbsp; for(; itNum &lt; thresholdVector.end(); itNum++)<br>&nbsp;&nbsp;&nbsp; {<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; const PixelType insideValue = count;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; filter-&gt;SetInsideValue( insideValue );<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; upperThreshold
 =static_cast&lt;PixelType&gt;(*itNum);<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; filter-&gt;SetLowerThreshold( lowerThreshold );<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; filter-&gt;SetUpperThreshold(upperThreshold );<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; filter-&gt;Update();<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lowerThreshold = upperThreshold;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; write_to_jpg&lt;unsigned char&gt;(gpResultsDir-&gt;GetFullPath("filter_out.jpg"), filter-&gt;GetOutput());<br><br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; addFilter-&gt;SetInput1( filter-&gt;GetOutput() );<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; addFilter-&gt;SetInput2(&nbsp; sumimage );<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; addFilter-&gt;Update();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sumimage = addFilter-&gt;GetOutput() ;<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; write_to_jpg&lt;unsigned short&gt;(gpResultsDir-&gt;GetFullPath("sumimage1.jpg"),
 sumimage);<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; count = count + step;<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; PixelType insideValue = 255;<br><br>&nbsp;&nbsp;&nbsp; filter-&gt;SetInsideValue( insideValue&nbsp;&nbsp; );<br>&nbsp;&nbsp;&nbsp; filter-&gt;SetLowerThreshold( lowerThreshold );<br>&nbsp;&nbsp;&nbsp; filter-&gt;SetUpperThreshold(max );<br>&nbsp;&nbsp;&nbsp;<span style="font-weight: bold;"> filter-&gt;Update();</span><br><br><br>Thank you for your help.<br><br>regards,<br>Emma<br></div></body></html>