Its likely that image is null.. you might be creating a smartpointer in function and passing it out a raw pointer.. Please use a debugger and read the guide about smart pointers.<br><br><div class="gmail_quote">On Mon, Nov 9, 2009 at 1:49 PM, Yili Pan <span dir="ltr">&lt;<a href="mailto:pyl0420@gmail.com">pyl0420@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi everyone:<div><br></div><div>I&#39;m trying to get a specific slice of the volume:</div><div>
<br></div><div><div>                        index[0]=sliceNum;</div><div><span style="white-space: pre;">                        </span>ImageType::RegionType regionImg;</div>
<div><span style="white-space: pre;">                        </span>ImageType::IndexType start;</div><div><span style="white-space: pre;">                        </span>start[0]=0;</div><div><span style="white-space: pre;">                        </span>start[1]=0;</div>
<div><span style="white-space: pre;">                        </span>ImageType::SizeType sizeImg;</div><div><span style="white-space: pre;">                        </span>sizeImg[0]=size[1];</div><div><span style="white-space: pre;">                        </span>sizeImg[1]=size[2];</div>

<div><span style="white-space: pre;">                        </span>regionImg.SetIndex(start);</div><div><span style="white-space: pre;">                        </span>regionImg.SetSize(sizeImg););</div><div><span style="white-space: pre;">                        </span>image-&gt;SetRegions(regionImg);</div>

<div><span style="white-space: pre;">                        </span>image-&gt;Allocate();</div><div>Then I use getPixel and setPixel to read the pixel value of volume and set the value of  corresponding  position.</div><div>
This method worked, but when I tried to write it as a function, the problem came.</div><div>The program broke at image-&gt;SetRegions(regionImg)</div><div><br></div><div>Could you help me with this problem? If I write it in the main function, the whole program would be very long</div>

<div><br></div><div>Thanks a lot!!</div><div><br></div><div>Best,</div><div>Yili</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.html" target="_blank">http://www.kitware.com/products/protraining.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></blockquote></div><br><br clear="all"><br>