Problem in combine axial, sagittal, coronal images to 3d image(.mha)

Hi everyone:
I need some help!
I make my demo and test data. (download from http://www.insight-journal.org/midas/bitstream/download/3527).
It works well.

But when i use axial, sagittal, coronal dicom images in three directories to display. 
It works bad. It seems all the dicom image is parallel, no orthogonal。

What can i do ?

The code is

using PixelType = signed short;
constexpr unsigned int InputDimension = 3;
constexpr unsigned int OutputDimension = 3;
using ReaderImageType = itk::Image<PixelType, InputDimension>;
using WriterImageType = itk::Image<PixelType, OutputDimension>;
using ReaderType = itk::ImageSeriesReader<ReaderImageType>;
using WriterType = itk::ImageFileWriter<WriterImageType>;

std::vector<std::string> files;   
for (size_t i = 0; i < series_uids.size(); i++) {
    std::string dir_path = series_uids[i];  //series_uids store the dicom image dir path. size == 3.

    itk::GDCMSeriesFileNames::Pointer namesgenerator = itk::GDCMSeriesFileNames::New();
    namesgenerator->SetUseSeriesDetails(true);
    namesgenerator->AddSeriesRestriction("0008|0021");
    namesgenerator->SetGlobalWarningDisplay(false);
    namesgenerator->SetDirectory(dir_path);
    const std::vector<std::string> &id = namesgenerator->GetSeriesUIDs();
    if (id.size() != 1) {
        continue;
    }
    std::vector<std::string> dicoms = namesgenerator->GetFileNames(id[0].c_str());

    files.insert(files.end(), dicoms.begin(), dicoms.end());
}

ReaderType::Pointer reader = ReaderType::New();
itk::GDCMImageIO::Pointer dicomIO = itk::GDCMImageIO::New();
reader->SetImageIO(dicomIO);
reader->SetFileNames(files);
reader->Update();

std::string output = "/home/demo.mha";
removeFile(output);
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(output);
writer->UseCompressionOn();
writer->SetInput(reader->GetOutput());
try {
    writer->Update();
}
catch (itk::ExceptionObject &ex) {
    std::cout << ex << std::endl;
}

Thanks in advance!

ImageSeriesReader assumes that all the images it gets belong to the same series, meaning having the same size and orientation and only differing by spatial position. By supplying it with multiple series you are violating that assumption.

You should look at this discussion and AddImageFilter and the examples which use it.

AddImageFilter doesn’t work. JoinSeriesImageFilter also fails.
The error output is “Inputs do not occupy the same physical space!”
I have no idea about it. Means to translate the 3d image to the same origin or spacing or direction?

Is there a class for processing multi series of dicom images in different direction?

Thank you very much!

What you need to do is pick some image grid (from the first image, or from the highest resolution image, or from the lowest resolution image, or some other similar criterion), determine bounding box which encompasses all the images and resample all the images onto that grid. Then you can use AddImageFilter.

If you don’t want to implement all of that, take a look at this and this, as @fbudin mentioned in this post.

Hi everyone, I have a similar problem…i have a 3D volume and i want to display the axial, sagittal and coronal slices on the same window…do u have any suggestions/classes/example i could use?
I need also to ‘scroll’ up and down my volume…for example, if im in the axial slice and click with the left button (or i do smt else), it would show me the ‘higher’ slice of that plane…
Thanks in advance

You might want to start with an existing application such as ITK-SNAP and simplify it.

Or you might add your algorithm to an existing extensible application such as 3D Slicer.

Also, you could take a look at a more primitive, but much simpler viewer which I wrote. It is called SegComparer, and is available here. And in addition to visualizing images, it can visualize and quantitatively compare different segmentations (e.g. manual and automatic).

Edit: that is research code from 5 years ago. Provided as-is, without support.

Hi dzenanz and thank u for your answer. Unfortunately, i have to do this using only ITK/VTK.
I have to read 200 dicom images, create a volume, segment the liver vessels and visualize them in a bynary mask. I also have to ‘highlight’ the vessels in my volume (i thought of simply ‘adding’ my mask to my volume) and to cut the volume and display the slices in axial,sagittal and coronal planes…

If you don’t want to use Qt, then you should look into VTK classes for displaying images. Examples: InteractWithImage, ImageMapper.