Hi Luis, I figured out why AddPixelAccessor wouldn&#39;t compile. I forgot that Accessors have their own name space. See attached for updated test code based on your example. The AddPixelAccessor Get() and Set() functions behave the way you described with Set() being in contradiction to the other accessors. Which way would be the correct way?<div>
<br></div><div>-Robert<br><div><div><div><br><div class="gmail_quote">On Fri, Dec 10, 2010 at 2:19 PM, robert tamburo <span dir="ltr">&lt;<a href="mailto:robert.tamburo@gmail.com">robert.tamburo@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Thanks for the response Luis. I&#39;m still confused though because none of the other pixel accessors use the Set() method for inverse operations, e.g., <span style="font-family:arial, sans-serif;font-size:13px;border-collapse:collapse">SqrtPixelAccessor, all of the trigonometric accessors, etc. I wrote some code using SqrtPixelAdaptor</span><span style="font-family:arial, sans-serif;border-collapse:collapse"> (AddPixelAccessor will not compile, see below) to test the Set() and Get() methods. </span><div>

<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">For an image set to 100: </span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">- Get() returns 10 as expected. </span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">- Set(10) sets the pixel to sqrt(10), and followed by Get() returns the sqrt(sqrt(10)), which is what you warned me about. </span></font><span style="font-family:arial, sans-serif;border-collapse:collapse">But is this the intended use of Set()?</span></div>

<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">Back to your example with AddPixelAccessor:</span></font></div>

<div><font face="arial, sans-serif"><span style="border-collapse:collapse">It is my understanding that image adaptors behave like images. So SetPixel would set the pixel value according to the pixel accessor used. So, by your example, SetPixel(12) would ultimately just set the pixel to &quot;7&quot;, which is the value of the input image. It allows Get() to be used correctly, but doesn&#39;t seem too useful.</span></font></div>

<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">Considering that itkAddPixelAccessor will not compile and there is no test for it, and that its Set() method does not follow the other Accessors, is it possible that the functionality for Set() was changed some time ago and </span></font><span style="font-family:arial, sans-serif;border-collapse:collapse">itkAddPixelAccessor  fell through the cracks?</span></div>

<div><span style="font-family:arial, sans-serif;border-collapse:collapse"><br></span></div><div><span style="font-family:arial, sans-serif;border-collapse:collapse">Thanks.</span></div>
<div><span style="font-family:arial, sans-serif;border-collapse:collapse"><br></span></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">********</span></font></div>
<div><div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><div><span style="border-collapse:separate;font-family:arial">I attempted to write test code for AddPixelAccessor, but am getting compile errors:</span></div>

</span></font></div><div>typedef itk::AddPixelAccessor&lt;float&gt; AddAccessorType;</div><div><div>itkAddPixelAccesor.h: No such file or directory </div></div><div><br></div><div>I made a copy of itkAddPixelAccesor.h (itkTestAddPixelAccessor.h), and received the following error:</div>

<div><div>error: expected initializer before&#39;&lt;&#39; token</div><div>which usually means the header wasn&#39;t included...</div><div><br></div><div>I moved #include &quot;itkTestAddPixelAccessor.h&quot; to the top of my include list and got the following error:</div>

<div><div>itkTestAddPixelAccessor.h:39: error: invalid function declaration</div></div><div><br></div><div>Consider me perplexed...</div><div class="im"><div><br></div><div>On Fri, Dec 10, 2010 at 5:53 AM, Luis Ibanez <span dir="ltr">&lt;<a href="mailto:luis.ibanez@kitware.com" target="_blank">luis.ibanez@kitware.com</a>&gt;</span> wrote:</div>

</div><div><div></div><div class="h5"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Robert, David<br>
<br>
<br>
The implementation is correct.<br>
<br>
<br>
You are confusing the role of the Set()  method with<br>
the role of the Get() method. One must apply the<br>
inverse operation of the other.<br>
<br>
<br>
An ImageAdaptor is intended to present an image<br>
as if the image had been processed by a filter.<br>
<br>
The PixelAccessor for that ImageAdaptor implements<br>
the trick of transforming the pixel on the fly.<br>
<br>
The AddImageAdaptor must present the image A<br>
as A+k (where &quot;k&quot; is a constant that it is added to<br>
every pixel in A).<br>
<br>
                           B  =  A + k<br>
<br>
The addition of K is implemented in the &quot;Get&quot; method.<br>
<br>
So, if your input image has a pixel with value &quot;7&quot;,<br>
and &quot;k&quot; has been set to &quot;5&quot;,<br>
<br>
then calling &quot;Get&quot; in that pixel should give you &quot;7+5=12&quot;<br>
<br>
To be consistent, the &quot;Set&quot; operation must be the<br>
inverse of the &quot;Get&quot; operation.<br>
<br>
So, if you &quot;Set&quot; a pixel to value &quot;12&quot;, the &quot;Set&quot; method<br>
must store in &quot;A&quot; the value &quot;12-5 = 7&quot;.<br>
<br>
In that way,  if you call &quot;Get&quot; later in that same pixel,<br>
you get your &quot;12&quot; back.<br>
<br>
<br>
   Regards,<br>
<br>
<br>
      Luis<br>
<br>
<br>
---------------------------------------------<br>
<div>On Thu, Dec 9, 2010 at 4:33 PM, robert tamburo &lt;<a href="mailto:robert.tamburo@gmail.com" target="_blank">robert.tamburo@gmail.com</a>&gt; wrote:<br>
</div><div><div></div><div>&gt; I&#39;m confused with the set function of AddPixelAccessor. It subtracts a value<br>
&gt; from the input rather than adding it.<br>
&gt; Relevant code:<br>
&gt; inline void Set( InternalType &amp; output, const ExternalType &amp; input ) const<br>
&gt;     { output = static_cast&lt;InternalType&gt;( input - m_Value ); }<br>
&gt; Shouldn&#39;t it add m_Value to the input? Or is there something else going on?<br>
&gt; -Robert<br>
&gt;<br>
</div></div><div><div></div><div>&gt; _____________________________________<br>
&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;<br>
&gt; Visit other Kitware open-source projects at<br>
&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;<br>
&gt; Kitware offers ITK Training Courses, for more information visit:<br>
&gt; <a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
&gt;<br>
&gt; Please keep messages on-topic and check the ITK FAQ at:<br>
&gt; <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
&gt;<br>
&gt; Follow this link to subscribe/unsubscribe:<br>
&gt; <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br></div></div></div></div></div></div>
</blockquote></div><br></div></div></div></div>