forked from daviddoria/SuperPixelSegmentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ITKSegmentationExample.cpp
33 lines (27 loc) · 1.1 KB
/
ITKSegmentationExample.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <itkImage.h>
#include <itkImageFileReader.h>
#include <itkImageFileWriter.h>
#include "itkSuperPixelSegmentation.h"
//typedef itk::Image<itk::CovariantVector<float, 3>, 2> ImageType;
typedef itk::VectorImage<float, 2> ImageType;
typedef itk::Image<int, 2> LabelImageType;
int main(int argc, char* argv[])
{
typedef itk::ImageFileReader<ImageType> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(argv[1]);
reader->Update();
typedef itk::SuperPixelSegmentation<ImageType, LabelImageType> SuperPixelSegmentationType;
SuperPixelSegmentationType::Pointer superPixelSegmentation = SuperPixelSegmentationType::New();
superPixelSegmentation->SetSigma(.5);
superPixelSegmentation->SetK(500);
superPixelSegmentation->SetMinSize(50);
superPixelSegmentation->SetInput(reader->GetOutput());
superPixelSegmentation->Update();
typedef itk::ImageFileWriter<LabelImageType> WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(argv[2]);
writer->SetInput(superPixelSegmentation->GetOutput());
writer->Update();
return EXIT_SUCCESS;
}