Hi, from your code, it seems that you forgot to allocate memory for your output image.<br>try to add<br>outputImage->SetRegions(inputMaskImage->GetBufferedRegion());<br>outputImage->Allocate();<br><br>before the loop.<br>
<br><br><br><br><a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>,<br><br><div class="gmail_quote">2009/4/20 shoosh moosh <span dir="ltr"><<a href="mailto:babygirl_25@hotmail.com">babygirl_25@hotmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
This is what I got when I printed them:<br><br>Image (0x857c040)<br> RTTI typeinfo: itk::Image<short, 3u><br> Reference Count: 2<br> Modified Time: 205<br> Debug: Off<br> Observers: <br> none<br> Source: (0x8579948) <br>
Source output index: 0<br> Release Data: Off<br> Data Released: False<br> Global Release Data: Off<br> PipelineMTime: 27<br> UpdateMTime: 206<br> LargestPossibleRegion: <br> Dimension: 3<br> Index: [0, 0, 0]<br>
Size: [540, 520, 720]<br> BufferedRegion: <br> Dimension: 3<br> Index: [0, 0, 0]<br> Size: [540, 520, 720]<br> RequestedRegion: <br> Dimension: 3<br> Index: [0, 0, 0]<br> Size: [540, 520, 720]<br> Spacing: [1, 1, 1]<br>
Origin: [0, 0, 0]<br> Direction
: <br>1 0 0<br>0 1 0<br>0 0 1<br><br> IndexToPointMatrix: <br> 1 0 0<br>0 1 0<br>0 0 1<br><br> PointToIndexMatrix: <br> 1 0 0<br>0 1 0<br>0 0 1<br><br> PixelContainer: <br> ImportImageContainer (0x857c1f8)<br> RTTI typeinfo: itk::ImportImageContainer<unsigned long, short><br>
Reference Count: 1<br> Modified Time: 203<br> Debug: Off<br> Observers: <br> none<br> Pointer: 0x9fb12008<br> Container manages memory: true<br> Size: 202176000<br> Capacity: 202176000<br>
Image (0x857e938)<br> RTTI typeinfo: itk::Image<unsigned char, 3u><br> Reference Count: 2<br> Modified Time: 3
57<br> Debug: Off<br> Observers: <br> none<br> Source: (0x857c240) <br> Source output index: 0<br> Release Data: Off<br> Data Released: False<br> Global Release Data: Off<br> PipelineMTime: 28<br> UpdateMTime: 358<br>
LargestPossibleRegion: <br> Dimension: 3<br> Index: [0, 0, 0]<br> Size: [540, 520, 720]<br> BufferedRegion: <br> Dimension: 3<br> Index: [0, 0, 0]<br> Size: [540, 520, 720]<br> RequestedRegion: <br> Dimension: 3<br>
Index: [0, 0, 0]<br> Size: [540, 520, 720]<br> Spacing: [1, 1, 1]<br> Origin: [0, 0, 0]<br> Direction: <br>1 0 0<br>0 1 0<br>0 0 1<br><br> IndexToPointMatrix: <br> 1 0 0<br>0 1 0<br>0 0 1<br><br> PointToIndexMatrix: <br>
1 0 0<br>0 1 0<br>0 0 1<br><br> Pi
xelContainer: <br> ImportImageContainer (0x857eaf0)<br> RTTI typeinfo: itk::ImportImageContainer<unsigned long, unsigned char><br> Reference Count: 1<br> Modified Time: 355<br> Debug: Off<br>
Observers: <br> none<br> Pointer: 0x93a42008<br> Container manages memory: true<br> Size: 202176000<br> Capacity: 202176000<br><br>I think they are the same size, right? However one is a an image of short's while the other is of unsigned char's.<br>
<br><br><br><br>> Date: Sun, 19 Apr 2009 15:35:53 -0400<div class="im"><br>> Subject: Re: [Insight-users] masking part of an image<br>> From: <a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a><br>
> To: <a href="mailto:babygirl_25@hotmail.com" target="_blank">babygirl_25@hotmail.com</a><br></div>&g
t; CC: <a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a><div><div></div><div class="h5"><br>> <br>> Are the input and input mask the same size? Try printing them.<br>> inputImage->Print(std::cout);<br>
> inputMaskImage->Print(std::cout);<br>> <br>> after the Update's<br>> <br>> 2009/4/19 shoosh moosh <<a href="mailto:babygirl_25@hotmail.com" target="_blank">babygirl_25@hotmail.com</a>>:<br>> > Ok, I added the reader->Update(), but now I'm getting a different error:<br>
> > Segmentation fault<br>> ><br>> > The program apparently crashes in the for loop.<br>> ><br>> > I think something might be wrong with lines 64-65, but I'm not sure what.<br>> > inputImage=reader1->GetOutput();<br>
> > inputMaskImage=reader2->GetOutput();<br>> ><br>> > I attached the code again.<br>> > Thanks<br>> ><br>> ><br>> ><br>> >> Date: Sun, 19 Apr 2009 14:57:47 -0400<br>> >> Subject: Re: [Insight-users] masking part of an image<br>
> >> From: <a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a><br>
> >> To: <a href="mailto:babygirl_25@hotmail.com" target="_blank">babygirl_25@hotmail.com</a><br>> >> CC: <a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a><br>> >><br>
> >> Do a reader1->Update() and reader2->Update() before accessing the<br>> >> outputs of the reader.<br>> >><br>> >> 2009/4/19 shoosh moosh <<a href="mailto:babygirl_25@hotmail.com" target="_blank">babygirl_25@hotmail.com</a>>:<br>
> >> > Hi,<br>> >> > I wrote up a program that takes as input 2 images - a 3D image, and a 3D<br>> >> > binary mask image with 0's in the parts im not interested and 1's in the<br>
> >> > parts I want to segment out. I want the program to simply multiply each<br>> >> > pixel in the original image with the corresponding pixel in the masking<br>> >> > image and produce a third image of the same size having only the region<br>
> >> > specified by 1's in the mask. The code compiles, but when I run it, I<br>> >> > get<br>> >> > this error:<br></div></div>> >> &
gt;<div class="im"><br>> >> > terminate called after throwing an instance of 'itk::ExceptionObject'<br>> >> > what():<br>> >> > /home/shoosh/InsightToolkit-3.10.2/Code/IO/itkNrrdImageIO.cxx:951:<br>
> >> > itk::ERROR: NrrdImageIO(0x8585a50): Write: Error wrapping nrrd for<br>> >> > output.nhdr:<br>> >> > [nrrd] nrrdWrap_nva:<br>> >> > [nrrd] _nrrdSizeCheck: axis 0 size is zero!<br>
> >> ><br>> >> > Can some one tell me how to fix it. the code is attached.<br>> >> ><br>> >> ><br>> >> ><br>> >> > ________________________________<br>
> >> > Get news, entertainment and everything you care about at Live.com. Check<br>> >> > it<br>> >> > out!<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>> >> > 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>> >> ><br>> ><br>> > ________________________________<br>> > See all the ways you can stay connected to friends and family<br><br><hr></div>What can you do with the new Windows Live? <a href="http://www.microsoft.com/windows/windowslive/default.aspx" target="_blank">Find out</a></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>
Please keep messages on-topic and check the ITK FAQ at: <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><br>