<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> 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. The program builds and executes fine in Release mode till it crashes at Filter->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 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 = <unsigned short, 2><br> UCharImageType = <unsigned char, 2><br><br><br>//code snippet<br>typedef
itk::Statistics::ScalarImageToHistogramGenerator<ImageType > ScalarImageToHistogramGeneratorType;<br> typedef itk::OtsuMultipleThresholdsCalculator<ScalarImageToHistogramGeneratorType::HistogramType > CalculatorType;<br> typedef itk::BinaryThresholdImageFilter< ImageType, UCharImageType > FilterType;<br> typedef itk::AddImageFilter< UCharImageType, ImageType ,ImageType> AddFilterType;<br><br> ScalarImageToHistogramGeneratorType::Pointer scalarImageToHistogramGenerator = ScalarImageToHistogramGeneratorType::New();<br> CalculatorType::Pointer calculator = CalculatorType::New();<br> FilterType::Pointer filter = FilterType::New();<br> AddFilterType::Pointer addFilter = AddFilterType::New();<br><br><br> int num_of_bins =
128;<br> int num_thresholds = 2;<br> scalarImageToHistogramGenerator->SetNumberOfBins( num_of_bins );<br> calculator->SetNumberOfThresholds(num_thresholds);<br> scalarImageToHistogramGenerator->SetInput(mpImage);<br> scalarImageToHistogramGenerator->Compute();<br> calculator->SetInputHistogram(scalarImageToHistogramGenerator->GetOutput());<br> filter->SetInput(mpImage );<br><br> calculator->Update();<br><br> const CalculatorType::OutputType &thresholdVector = calculator->GetOutput();<br> CalculatorType::OutputType::const_iterator itNum = thresholdVector.begin();<br><br> PixelType min = 0;<br> PixelType max = 255;<br><br> const PixelType outsideValue = 0;<br><br>
//std::string outputFileBase = argv[2];<br> //std::string outputFile;<br> //std::string format = argv[2];<br><br> //char outputFilename[1000];<br> //outputFile = outputFileBase;<br> //outputFile += argv[3]; // filename extension<br><br> PixelType lowerThreshold = min;<br> PixelType upperThreshold;<br><br> filter->SetOutsideValue(outsideValue );<br> PixelType step =(255/(num_thresholds+1) );<br> PixelType count=step;<br><br> for(; itNum < thresholdVector.end(); itNum++)<br> {<br><br> const PixelType insideValue = count;<br> filter->SetInsideValue( insideValue );<br><br> upperThreshold
=static_cast<PixelType>(*itNum);<br><br> filter->SetLowerThreshold( lowerThreshold );<br> filter->SetUpperThreshold(upperThreshold );<br> filter->Update();<br><br> lowerThreshold = upperThreshold;<br> write_to_jpg<unsigned char>(gpResultsDir->GetFullPath("filter_out.jpg"), filter->GetOutput());<br><br><br> addFilter->SetInput1( filter->GetOutput() );<br> addFilter->SetInput2( sumimage );<br><br> addFilter->Update();<br> sumimage = addFilter->GetOutput() ;<br><br> write_to_jpg<unsigned short>(gpResultsDir->GetFullPath("sumimage1.jpg"),
sumimage);<br><br> count = count + step;<br> }<br><br> PixelType insideValue = 255;<br><br> filter->SetInsideValue( insideValue );<br> filter->SetLowerThreshold( lowerThreshold );<br> filter->SetUpperThreshold(max );<br> <span style="font-weight: bold;"> filter->Update();</span><br><br><br>Thank you for your help.<br><br>regards,<br>Emma<br></div></body></html>