SimpleITK  
DicomSeriesReader/DicomSeriesReader.cxx
/*=========================================================================
*
* Copyright NumFOCUS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
// This one header will include all SimpleITK filters and external
// objects.
#include <SimpleITK.h>
#include <iostream>
#include <stdlib.h>
// create convenient namespace alias
namespace sitk = itk::simple;
int main ( int argc, char* argv[] ) {
if ( argc < 3 ) {
std::cerr << "Usage: " << argv[0] << " <input_directory> <output_file>\n";
return 1;
}
std::cout << "Reading Dicom directory: " << argv[1] << std::endl;
// Read the Dicom image series
const std::vector<std::string> dicom_names = sitk::ImageSeriesReader::GetGDCMSeriesFileNames( argv[1] );
reader.SetFileNames( dicom_names );
sitk::Image image = reader.Execute();
std::vector<unsigned int> size = image.GetSize();
std::cout << "Image size: " << size[0] << " " << size[1] << " " << size[2] << std::endl;
std::cout << "Writing " << argv[2] << std::endl;
sitk::WriteImage( image, argv[2] );
if (getenv("SITK_NOSHOW") == NULL)
sitk::Show( image, "Hello World: C++", true );
return 0;
}
itk::simple::Image
The Image class for SimpleITK.
Definition: sitkImage.h:76
itk::simple::ImageSeriesReader::SetFileNames
Self & SetFileNames(const std::vector< std::string > &fileNames)
itk::simple::Show
void SITKIO_EXPORT Show(const Image &image, const std::string &title="", const bool debugOn=ProcessObject::GetGlobalDefaultDebug())
SimpleITK.h
itk::simple::ImageSeriesReader::GetGDCMSeriesFileNames
static std::vector< std::string > GetGDCMSeriesFileNames(const std::string &directory, const std::string &seriesID="", bool useSeriesDetails=false, bool recursive=false, bool loadSequences=false)
Generate a sequence of filenames from a directory with a DICOM data set and a series ID.
itk::simple::Image::GetSize
std::vector< unsigned int > GetSize() const
itk::simple::ImageSeriesReader::Execute
Image Execute() override
Set/Get The output PixelType of the image.
itk::simple::ImageSeriesReader
Read series of image files into a SimpleITK image.
Definition: sitkImageSeriesReader.h:55
itk::simple::WriteImage
SITKIO_EXPORT void WriteImage(const Image &image, const std::string &fileName, bool useCompression=false, int compressionLevel=-1)
WriteImage is a procedural interface to the ImageFileWriter. class which is convenient for many image...
itk::simple
Definition: sitkAdditionalProcedures.h:28