<div dir="ltr"><div><div>Thanks guys. My requirement is kind of just using ITK. It is an assignment actually.<br></div>Can you guys help me out what am I doing wrong here. I have busted my head over this for the whole day. I am getting like 30 errors :'(<br>
</div><br>The code:<br><br>#include "itkImage.h"<br>#include "itkImageFileReader.h"<br>#include "itkImageFileWriter.h"<br>#include "itkRescaleIntensityImageFilter.h"<br>#include "itkMultiplyImageFilter.h"<br>
<br>int main( int argc, char * argv[] )<br>{<br> if( argc < 4 )<br> {<br> std::cerr << "Usage: " << argv[0];<br> std::cerr << " image1 image2 ";<br> std::cerr << "outputImagefile " << std::endl;<br>
return EXIT_FAILURE;<br> }<br> <br> typedef unsigned char PixelType;<br> const unsigned int Dimension = 3;<br> typedef itk::Image< PixelType, Dimension > Image1Type;<br> typedef itk::Image< PixelType, Dimension > Image2Type;<br>
<br> typedef itk::ImageFileReader< Image1Type > Image1ReaderType;<br> typedef itk::ImageFileReader< Image2Type > Image2ReaderType;<br><br><br> Image1ReaderType::Pointer Image1Reader = Image1ReaderType::New();<br>
Image2ReaderType::Pointer Image2Reader = Image2ReaderType::New();<br><br> Image1Reader->SetFileName( argv[1] );<br> Image2Reader->SetFileName( argv[2] );<br><br> typedef itk::MultiplyImageFilter <Image1ReaderType, Image2ReaderType > <br>
MultiplyImageFilterType;<br><br> MultiplyImageFilterType::Pointer multiplyFilter = MultiplyImageFilterType::New ();<br> multiplyFilter->SetInput1(Image1Reader);<br> multiplyFilter->SetInput2(Image2Reader); <br>
<br> typedef itk::Image< PixelType, Dimension > OutputImageType; <br> typedef itk::ImageFileWriter< OutputImageType > WriterType;<br> WriterType::Pointer writer = WriterType::New();<br> writer->SetFileName( argv[3] );<br>
writer->SetInput( multiplyFilter->GetOutput() );<br> writer->Update();<br><br> return EXIT_SUCCESS;<br>}<br><div><br><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Apr 27, 2014 at 7:00 PM, Bradley Lowekamp <span dir="ltr"><<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
You may be interested in the SimpleITK bindings for ITK. SimpleITK provides an easy to use interface on top of ITK which excels facilitation quick image manipulation with ITK, and enables interactive manipulations with tools such as IPython[1]<br>
<br>
SimpleITK for python is readily available as a binary download[2]. What you are looking for can be done in SimpleITK like this:<br>
<br>
import SimpleITK as sitk<br>
img1 = sitk.ReadImage("head.img")<br>
img2 = sitk.ReadImage("BrainMask.img")<br>
out = img1*img2<br>
sitk.WriteImage("out.img")<br>
<br>
This assumes that the two images occupy the same physical space and are the same pixel type. The binary operators in SimpleITK require that the pixel types are the same, so a cast may be needed.<br>
<br>
However, if you are multiplying a mask by the grayscale you may be interested in the MaskImageFilter[3]. This filter will support most combinations and can be used:<br>
<br>
sitk.Mask(img1, img2).<br>
<br>
Enjoy,<br>
Brad<br>
<br>
[1] <a href="http://simpleitk.github.io/SimpleITK-Notebooks/" target="_blank">http://simpleitk.github.io/SimpleITK-Notebooks/</a><br>
[2] <a href="http://www.itk.org/Wiki/SimpleITK/GettingStarted#Downloading_the_binaries" target="_blank">http://www.itk.org/Wiki/SimpleITK/GettingStarted#Downloading_the_binaries</a><br>
[3] <a href="http://www.itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_1MaskImageFilter.html" target="_blank">http://www.itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_1MaskImageFilter.html</a><br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
<br>
<br>
<br>
On Apr 27, 2014, at 1:39 AM, Pansam Changmi <<a href="mailto:pansam5green@gmail.com">pansam5green@gmail.com</a>> wrote:<br>
<br>
> Hi,<br>
><br>
> 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?<br>
><br>
> Regards,<br>
> Pansam<br>
</div></div><div class="HOEnZb"><div class="h5">> _____________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Kitware offers ITK Training Courses, for more information visit:<br>
> <a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
><br>
> Please keep messages on-topic and check the ITK FAQ at:<br>
> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br>
</div></div></blockquote></div><br></div>