<div dir="ltr"><div>Hi,<br><br></div>I didn't follow everything in detail, but it looks
 as if you're trying to pass an image with PixelType unsigned short to a
 writer which expects an image with PixelType unsigned char, which wont 
work. Please also be aware of the value ranges of the PixelTypes you 
declare. Multiplying two short ints can easily lead to overflow when 
casting to unsigned char. I'd even be careful casting them to short 
unless I am very certain about the expected intensity range in the 
images.<br><br>HTH<br>Tobias</div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-04-27 12:20 GMT+02:00 Tobias Gass <span dir="ltr"><<a href="mailto:tobiasgass@gmail.com" target="_blank">tobiasgass@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi,<br><br></div>I didn't follow everything in detail, but it looks as if you're trying to pass an image with PixelType unsigned short to a writer which expects an image with PixelType unsigned char, which wont work. Please also be aware of the value ranges of the PixelTypes you declare. Multiplying two short ints can easily lead to overflow when casting to unsigned char. I'd even be careful casting them to short unless I am very certain about the expected intensity range in the images.<br>

<br>HTH<br>Tobias<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-04-27 11:15 GMT+02:00 Pansam Changmi <span dir="ltr"><<a href="mailto:pansam5green@gmail.com" target="_blank">pansam5green@gmail.com</a>></span>:<div>
<div class="h5"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Thanks Christopher,<br><br></div>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:<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 << " fixedImageFile  movingImageFile ";<br>    std::cerr << "outputImagefile " << std::endl;<br>


    return EXIT_FAILURE;<br>    }<br> <br>  typedef  unsigned short  PixelType;<br>  const   unsigned int        Dimension = 3;<br>  typedef itk::Image< PixelType, Dimension >  FixedImageType;<br>  typedef itk::Image< PixelType, Dimension >  MovingImageType;<br>


 <br>  typedef itk::ImageFileReader< FixedImageType  > FixedImageReaderType;<br>  typedef itk::ImageFileReader< MovingImageType > MovingImageReaderType;<br><br>  FixedImageReaderType::Pointer  fixedImageReader  = FixedImageReaderType::New();<br>


  MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New();<br><br>  fixedImageReader->SetFileName( argv[1] );<br>  movingImageReader->SetFileName( argv[2] );<br><br>  typedef itk::MultiplyImageFilter <FixedImageReaderType, MovingImageReaderType >  <br>


      MultiplyImageFilterType;<br><br>  MultiplyImageFilterType::Pointer multiplyFilter<br>    = MultiplyImageFilterType::New ();<br>  multiplyFilter->SetInput1(fixedImageReader);<br>  multiplyFilter->SetInput2(movingImageReader);<br>


    <br>  typedef  unsigned char  OutputPixelType;<br><br>  typedef itk::Image< OutputPixelType, Dimension > OutputImageType;<br><br>  typedef itk::ImageFileWriter< OutputImageType >  WriterType;<br><br>  WriterType::Pointer      writer =  WriterType::New();<br>


<br>  writer->SetFileName( argv[3] );<br><br>  writer->SetInput( multiplyFilter->GetOutput() );<br>  writer->Update();<br><br>  return EXIT_SUCCESS;<br>}<br><br><br></div><div><div><div class="gmail_extra">
<br><br><div class="gmail_quote">
On Sun, Apr 27, 2014 at 11:14 AM, Christopher Mullins <span dir="ltr"><<a href="mailto:christopher.mullins@kitware.com" target="_blank">christopher.mullins@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<p dir="ltr">This example might help. You can delete the VTK-viewer bit if you want, should only need ITK. </p>
<p dir="ltr"><a href="http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/MultiplyImageFilter" target="_blank">http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/MultiplyImageFilter</a></p>
<div class="gmail_quote"><div><div>On Apr 27, 2014 1:40 AM, "Pansam Changmi" <<a href="mailto:pansam5green@gmail.com" target="_blank">pansam5green@gmail.com</a>> wrote:<br type="attribution"></div>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>
<div dir="ltr"><div><div><div>Hi,<br><br></div>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></div>Regards,<br></div>



Pansam<br>
</div>
<br></div></div>_____________________________________<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></blockquote></div>
</blockquote></div><br></div>
</div></div><br>_____________________________________<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></blockquote></div></div></div><br></div>
</blockquote></div><br></div>