[ITK] [ITK-users] Multiply two .img or .hdr images in ITK
Pansam Changmi
pansam5green at gmail.com
Sun Apr 27 05:15:41 EDT 2014
Thanks Christopher,
I removed the VTK viewer part and instead of creating two images I edited
the code to read tow ".hdr" files and write one ".hdr" output file. But I
am getting the following errors. I couldn't figure out the problem. Given
below is multiplyFilter.cxx code:
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkRescaleIntensityImageFilter.h"
#include "itkMultiplyImageFilter.h"
int main( int argc, char * argv[] )
{
if( argc < 4 )
{
std::cerr << "Usage: " << argv[0];
std::cerr << " fixedImageFile movingImageFile ";
std::cerr << "outputImagefile " << std::endl;
return EXIT_FAILURE;
}
typedef unsigned short PixelType;
const unsigned int Dimension = 3;
typedef itk::Image< PixelType, Dimension > FixedImageType;
typedef itk::Image< PixelType, Dimension > MovingImageType;
typedef itk::ImageFileReader< FixedImageType > FixedImageReaderType;
typedef itk::ImageFileReader< MovingImageType > MovingImageReaderType;
FixedImageReaderType::Pointer fixedImageReader =
FixedImageReaderType::New();
MovingImageReaderType::Pointer movingImageReader =
MovingImageReaderType::New();
fixedImageReader->SetFileName( argv[1] );
movingImageReader->SetFileName( argv[2] );
typedef itk::MultiplyImageFilter <FixedImageReaderType,
MovingImageReaderType >
MultiplyImageFilterType;
MultiplyImageFilterType::Pointer multiplyFilter
= MultiplyImageFilterType::New ();
multiplyFilter->SetInput1(fixedImageReader);
multiplyFilter->SetInput2(movingImageReader);
typedef unsigned char OutputPixelType;
typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
typedef itk::ImageFileWriter< OutputImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName( argv[3] );
writer->SetInput( multiplyFilter->GetOutput() );
writer->Update();
return EXIT_SUCCESS;
}
On Sun, Apr 27, 2014 at 11:14 AM, Christopher Mullins <
christopher.mullins at kitware.com> wrote:
> This example might help. You can delete the VTK-viewer bit if you want,
> should only need ITK.
>
> http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/MultiplyImageFilter
> On Apr 27, 2014 1:40 AM, "Pansam Changmi" <pansam5green at gmail.com> wrote:
>
>> Hi,
>>
>> Can anyone tell me how to multiply two .img or .hdr images (for example
>> head.img and BrainMask.img) in ITK? Do I need VTK? ITK-Snap? C3d tool?
>>
>> Regards,
>> Pansam
>>
>> _____________________________________
>> 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:
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20140427/958012b5/attachment-0002.html>
-------------- next part --------------
_____________________________________
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:
http://www.itk.org/mailman/listinfo/insight-users
More information about the Community
mailing list