[Insight-users] JoinImageFilter
Miller, James V (Research)
millerjv at crd.ge.com
Mon, 15 Mar 2004 09:21:01 -0500
JoinImageFilter is designed to combine two input images into a single
output vector image. For instance, you can give it two scalar images as
input and the output will be have a vector at each pixel with two
components. Or you can give it a scalar image and a vector image and the
output will be a vector image. The "join" is in analagous to a database
"join" query.
I think you will need to use the PasteImageFilter. To do what you want, you
will need to create an image that is the size of your two image sets
combined, the run through two PasteImageFilters to paste the first image in
the first part of the result and then a second PasteImageFilter to past the
second image into the second part of the result.
I have been meaning to put together an AppendImageFilter that will take two
stacks of images and create a single image that has the two datasets
appended along a designated axis.
-----Original Message-----
From: Rahul Chander
To: Insight-users at itk.org
Sent: 3/14/2004 6:17 AM
Subject: [Insight-users] JoinImageFilter
Hi,
I am trying to combine two 3D images (vtk files) of the same
dimensions along the z direction. Image 2 is set of consecutive
slices in sequence with the Image 1 set. I am using JoinImageFilter
for this purpose. My problem is that I do not know how to specify
that I want image 2 to be appended to image 1 along the z direction
rather than some other default direction. Also my output does not
seem to be correct. Is this the right filter for my application?
Are there any better ways of tackling this problem?
Thanks in advance.
Rahul.
#include "itkImage.h"
#include "itkVTKImageIO.h"
#include "itkJoinImageFilter.h"
int main(int argc, char * argv[])
{
typedef itk::Image<unsigned char,3> Image3DType;
typedef itk::JoinImageFilter< Image3DType, Image3DType >
FilterType;
typedef itk::ImageFileReader<Image3DType> ReaderType;
typedef itk::ImageFileWriter<Image3DType> WriterType;
FilterType::Pointer filter = FilterType::New();
ReaderType::Pointer reader1 = ReaderType::New();
ReaderType::Pointer reader2 = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
reader1->SetFileName(argv[1]); // first 3D file 256x256x18
reader2->SetFileName(argv[2]); // second 3D file 256x256x18
//
Image3DType::Pointer Image1= reader1->GetOutput();
Image3DType::Pointer Image2= reader2->GetOutput();
filter->SetInput1(Image1);
filter->SetInput2(Image2);
writer->SetFileName("output/combined.vtk");
//output file goes in the folder called "output"
writer->SetInput((Image3DType*)filter->GetOutput());
// The output type of the filter is Vector, so I
// am typecasting it to Image3DType.
try {
writer->Update();
}
catch (itk::ExceptionObject &err) {
std::cout << "Exception Object caught: " << std::endl;
std::cout << err << std::endl;
return -1;
}
return 0;
}
--
===================================
Rahul Chander
IV Year Electrical Eng.
The University of British Columbia
Registered Linux User:207994
===================================
_______________________________________________
Insight-users mailing list
Insight-users at itk.org
http://www.itk.org/mailman/listinfo/insight-users