Hello Luis,<br><br><div class="gmail_quote">On Fri, May 28, 2010 at 5:35 PM, Luis Ibanez <span dir="ltr">&lt;<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<br>Hi Frederic,<br><br>The function:<div class="im"><br><span style="font-family: courier new,monospace;">     
template&lt;typename TITKImgType&gt;</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">     bool</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">     WriteFile(</span><br style="font-family: courier new,monospace;">




<span style="font-family: courier new,monospace;">         const 
std::string&amp; a_fullFilename,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">     
    typename TITKImgType::<span style="background-color: rgb(255, 255, 153);">ConstPointer</span>);</span><br>

<br></div>will be better written as<div class="im"><br><span style="font-family: courier new,monospace;">     
template&lt;typename TITKImgType&gt;</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">     bool</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">     WriteFile(</span><br style="font-family: courier new,monospace;">




<span style="font-family: courier new,monospace;">         const 
std::string&amp; a_fullFilename,</span><br style="font-family: courier new,monospace;"></div><span style="font-family: courier new,monospace;">     
    const TITKImgType * );</span><br>

<br><br>and you will be able to call it as<br><br>    ImgType::Pointer image = filter-&gt;GetOutput();<br><br>    WriteFile&lt;ImgType&gt;(&quot;out.mhd&quot;, image<span style="background-color: rgb(255, 255, 153);"> </span>);<br>


<br><br>(not need to use &quot;GetPointer()&quot; in this case)<br><br>Normally you don&#39;t need to call GetPointer() in ITK.<br></blockquote><div><br>Thank you very much, that works fine.<br><br>Following your indications, I&#39;ve just checked it works as expected with this simple code, for completeness:<br>

<br><div style="margin-left: 40px; font-family: courier new,monospace;">#include &lt;itkImage.h&gt;<br>#include &lt;itkImageFileReader.h&gt;<br>#include &lt;itkImageRegionIterator.h&gt;<br><br>typedef short PxlType;<br>typedef itk::Image&lt;PxlType, 3&gt; ImgType;<br>

<br>void<br>TryInspectors(<span style="background-color: rgb(255, 255, 153);">const ImgType* a_img</span>) {<br>  const ImgType::IndexType idx = { 0, 0, 0 };<br>  <span style="background-color: rgb(153, 255, 153);">a_img-&gt;GetPixel(idx);</span><br>

<br>  const ImgType::RegionType region = a_img-&gt;GetLargestPossibleRegion();<br>  <span style="background-color: rgb(153, 255, 153);">itk::ImageRegionConstIterator&lt;ImgType&gt; it(a_img, region);</span><br><br>  <span style="background-color: rgb(255, 204, 204);">// The following mutating methods cause compiler error, as expected:</span><br style="background-color: rgb(255, 204, 204);">

<span style="background-color: rgb(255, 204, 204);"><span style="background-color: rgb(255, 255, 255);">  </span>a_img-&gt;SetPixel(idx, 666); // &lt;- discards qualifiers</span><br style="background-color: rgb(255, 204, 204);">

<span style="background-color: rgb(255, 204, 204);"><span style="background-color: rgb(255, 255, 255);">  </span>itk::ImageRegionIterator&lt;ImgType&gt; it(a_img, region); // &lt;- invalid conversion</span><br>}<br><br>int main(int argc, char** argv) {<br>

  if (argc &lt; 2)<br>    return -1;<br><br>  typedef itk::ImageFileReader&lt;ImgType&gt; ReaderType;<br>  ReaderType::Pointer reader = ReaderType::New();<br>  reader-&gt;SetFileName(argv[1]);<br>  reader-&gt;Update();<br>

<br>  <span style="background-color: rgb(255, 255, 153);">ImgType::ConstPointer image = reader-&gt;GetOutput();</span><br>  TryInspectors(image);<br><br>  return 0;<br>}<br></div><br>Time to get rid of <span style="font-family: courier new,monospace;">GetPointer() </span>calls in our code!<br>

<br>Kind regards,<br><br>Frederic Perez<br></div></div><div style="visibility: hidden; display: inline;" id="avg_ls_inline_popup"></div><style type="text/css">#avg_ls_inline_popup {  position:absolute;  z-index:9999;  padding: 0px 0px;  margin-left: 0px;  margin-top: 0px;  width: 240px;  overflow: hidden;  word-wrap: break-word;  color: black;  font-size: 10px;  text-align: left;  line-height: 13px;}</style>