[ITK] [ITK-users] 3D volume of Stacked 2D images have different size from the 2D images
Shrabani Ghosh
srbn.ghosh99 at gmail.com
Mon Jun 24 13:45:22 EDT 2019
Hi,
I have stacked all the 2D slices of the images. But the 3D volume I am
getting has different height-width than the 2D images. The snapshot is the
size of one 2D image and outline of 3D volume. How is it changing the sizes?
<http://itk-insight-users.2283740.n2.nabble.com/file/t396636/11.png>
Here is my create3Dvolume code:
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkTileImageFilter.h"
#include <iostream>
#include <Windows.h>
#include <string>
#include <boost/filesystem.hpp>
using namespace std;
using namespace boost::filesystem;
int main(int argc, const char* argv[])
{
int x;
int j = 1;
const unsigned int InputDimension = 3;
const unsigned int OutputDimension = 3;
typedef unsigned char PixelType;
typedef itk::Image< PixelType, InputDimension > InputImageType;
typedef itk::Image< PixelType, OutputDimension > OutputImageType;
typedef itk::ImageFileReader< InputImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New();
typedef itk::TileImageFilter< InputImageType, OutputImageType > FilterType;
FilterType::Pointer filter = FilterType::New();
itk::FixedArray< unsigned int, OutputDimension > layout;
layout[0] = 1;
layout[1] = 1;
layout[2] = 0;
filter->SetLayout(layout);
std::string s ;
path p("E:\\Programs\\Extract2dfrom3d\\ctmoving1");
{
if (!is_directory(ii->path())) //we eliminate directories
{
// if (j == 20) break;
s = ii->path().string();
reader->SetFileName(s.c_str());
}
try
{
reader->Update();
}
catch (itk::ExceptionObject & e)
{
std::cerr << e << std::endl;
getchar();
return EXIT_FAILURE;
}
InputImageType::Pointer input = reader->GetOutput();
input->DisconnectPipeline();
filter->SetInput(j - 1, input);
}
const PixelType defaultValue = 0;
filter->SetDefaultPixelValue(defaultValue);
typedef itk::ImageFileWriter< OutputImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName("E:\\Programs\\Extract2dfrom3d\\ctmoving1\\ctmoving1.mhd");
writer->SetInput(filter->GetOutput());
writer->Update();
try
{
writer->Update();
}
catch (itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
std::cin >> x;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
Thank You
--
Sent from: http://itk-insight-users.2283740.n2.nabble.com/
The ITK community is transitioning from this mailing list to discourse.itk.org. Please join us there!
________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php
Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ
Follow this link to subscribe/unsubscribe:
https://itk.org/mailman/listinfo/insight-users
More information about the Community
mailing list