Can you tell me how to handle possible errors when I run simpleitk code ?
Here is an example:
#include "sitkImage.h"
#include "sitkCurvatureFlowImageFilter.h"
#include "sitkConnectedThresholdImageFilter.h"
#include "sitkImageFileReader.h"
#include "sitkImageFileWriter.h"
#include <stdlib.h>
#include <iostream>
namespace sitk = itk::simple;
int main(int argc, char* argv[])
{
//
// Read the image
//
sitk::ImageFileReader reader;
reader.SetFileName("d:\\tempx\\3DSlice1.dcm");
sitk::Image image = reader.Execute();
//
// Blur using CurvatureFlowImageFilter
//
sitk::CurvatureFlowImageFilter blurFilter;
blurFilter.SetNumberOfIterations(5);
blurFilter.SetTimeStep(0.125);
image = blurFilter.Execute(image);
//
// Set up ConnectedThresholdImageFilter for segmentation
//
sitk::ConnectedThresholdImageFilter segmentationFilter;
segmentationFilter.SetLower(1600);
segmentationFilter.SetUpper(2400);
segmentationFilter.SetReplaceValue(255);
// for (int i = 5; i + 1 < argc; i += 2)
{
std::vector<unsigned int> seed;
seed.push_back(50);
seed.push_back(100);
segmentationFilter.AddSeed(seed);
std::cout << "Adding a seed at: ";
for (unsigned int j = 0; j < seed.size(); ++j)
{
std::cout << seed[j] << " ";
}
std::cout << std::endl;
}
sitk::Image outImage = segmentationFilter.Execute(image);
//
// Write out the resulting file
//
sitk::ImageFileWriter writer;
writer.SetFileName("d:\\tempx\\3DSlice1XXX.dcm");
writer.Execute(outImage);
return 0;
}
at line
sitk::Image outImage = segmentationFilter.Execute(image);
my VS2017 jumpt to:
in real world this should not gonna happen … I have to handle somehow the errors … how can I do that ?
Flaviu.