From 7602df695e794d9c121ee622388484b580043ede Mon Sep 17 00:00:00 2001 From: alexandergetka Date: Sat, 28 May 2022 03:24:43 -0400 Subject: [PATCH 1/2] Update GeodesicSegmentation.cxx --- src/applications/GeodesicSegmentation.cxx | 34 ++++++++++++++++------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/applications/GeodesicSegmentation.cxx b/src/applications/GeodesicSegmentation.cxx index 0c76f6e8c..6b8910217 100644 --- a/src/applications/GeodesicSegmentation.cxx +++ b/src/applications/GeodesicSegmentation.cxx @@ -309,15 +309,28 @@ int main(int argc, char **argv) unsigned short threshold = 0; if (parser.isPresent("t")) { - std::string temp; + int temp; parser.getParameterValue("t", temp); - threshold = std::atoi(temp.c_str()); + threshold = temp; } std::cout << "Reading inputs.\n"; using ImageType = itk::Image< float, 3 >; + using ImageTypeGeodesic = itk::Image < short, 3 >; auto inputImage = cbica::ReadImage< ImageType >(inputFile); auto mask = cbica::ReadImage< ImageType >(drawingFile); + using CastFilterType = itk::CastImageFilter; + auto castFilter = CastFilterType::New(); + castFilter->SetInput(inputImage); + castFilter->Update(); + auto convertedInputImage = castFilter->GetOutput(); + using RescaleFilterType = itk::RescaleIntensityImageFilter; + auto rescaleFilter = RescaleFilterType::New(); + rescaleFilter->SetInput(convertedInputImage); + rescaleFilter->SetOutputMinimum(0); + rescaleFilter->SetOutputMaximum(255); + rescaleFilter->Update(); + convertedInputImage = rescaleFilter->GetOutput(); VectorVectorDouble Indices; typedef itk::ImageRegionIteratorWithIndex IteratorType; @@ -338,15 +351,15 @@ int main(int argc, char **argv) } std::cout << "Performing Geodesic map estimation.\n"; - GeodesicSegmentation< ImageType > segmentationClass; - auto geosOutput = segmentationClass.Run/*< ImageType >*/(inputImage, Indices); + GeodesicSegmentation< ImageTypeGeodesic > segmentationClass; + auto geosOutput = segmentationClass.Run/*< ImageType >*/(convertedInputImage, Indices); ImageType::PixelType maxVal; if (normalize) { std::cout << "Performing normalization.\n"; maxVal = 255; - auto rescaleFilter = itk::RescaleIntensityImageFilter< ImageType >::New(); + auto rescaleFilter = itk::RescaleIntensityImageFilter< ImageTypeGeodesic >::New(); rescaleFilter->SetInput(geosOutput); rescaleFilter->SetOutputMinimum(0); rescaleFilter->SetOutputMaximum(maxVal); @@ -355,7 +368,7 @@ int main(int argc, char **argv) } else { - auto calculator = itk::MinimumMaximumImageCalculator< ImageType >::New(); + auto calculator = itk::MinimumMaximumImageCalculator< ImageTypeGeodesic >::New(); calculator->SetImage(geosOutput); calculator->ComputeMaximum(); maxVal = calculator->GetMaximum(); @@ -364,18 +377,19 @@ int main(int argc, char **argv) if (threshold != 0) { std::cout << "Performing threshold with threshold = " << threshold << ".\n"; - auto thresholder = itk::BinaryThresholdImageFilter< ImageType, ImageType >::New(); + auto thresholder = itk::BinaryThresholdImageFilter< ImageTypeGeodesic, ImageTypeGeodesic >::New(); thresholder->SetInput(geosOutput); thresholder->SetOutsideValue(0); thresholder->SetInsideValue(1); - thresholder->SetLowerThreshold(threshold); - thresholder->SetUpperThreshold(maxVal); + thresholder->SetLowerThreshold(0); + thresholder->SetUpperThreshold(threshold); + //thresholder->ThresholdAb thresholder->Update(); geosOutput = thresholder->GetOutput(); } std::cout << "Writing Output File:\n" + outputFile + "\n"; - cbica::WriteImage< ImageType >(geosOutput, outputFile); + cbica::WriteImage< ImageTypeGeodesic >(geosOutput, outputFile); } std::cout << "Finished Successfully.\n"; From 470ff958fca164db7de2d3650b10727d559f2d2f Mon Sep 17 00:00:00 2001 From: alexandergetka Date: Sat, 28 May 2022 03:28:50 -0400 Subject: [PATCH 2/2] remove needless comment --- src/applications/GeodesicSegmentation.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/applications/GeodesicSegmentation.cxx b/src/applications/GeodesicSegmentation.cxx index 6b8910217..0f129cb1d 100644 --- a/src/applications/GeodesicSegmentation.cxx +++ b/src/applications/GeodesicSegmentation.cxx @@ -383,7 +383,6 @@ int main(int argc, char **argv) thresholder->SetInsideValue(1); thresholder->SetLowerThreshold(0); thresholder->SetUpperThreshold(threshold); - //thresholder->ThresholdAb thresholder->Update(); geosOutput = thresholder->GetOutput(); }