[Insight-users] AddPixelAccessor set function confusion

robert tamburo robert.tamburo at gmail.com
Fri Dec 10 16:06:21 EST 2010


Hi Luis, I figured out why AddPixelAccessor wouldn'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?

-Robert

On Fri, Dec 10, 2010 at 2:19 PM, robert tamburo <robert.tamburo at gmail.com>wrote:

> Thanks for the response Luis. I'm still confused though because none of the
> other pixel accessors use the Set() method for inverse operations, e.g., SqrtPixelAccessor,
> all of the trigonometric accessors, etc. I wrote some code using
> SqrtPixelAdaptor (AddPixelAccessor will not compile, see below) to test
> the Set() and Get() methods.
>
> For an image set to 100:
> - Get() returns 10 as expected.
> - Set(10) sets the pixel to sqrt(10), and followed by Get() returns the
> sqrt(sqrt(10)), which is what you warned me about. But is this the
> intended use of Set()?
>
> Back to your example with AddPixelAccessor:
> 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 "7", which is
> the value of the input image. It allows Get() to be used correctly, but
> doesn't seem too useful.
>
> 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 itkAddPixelAccessor
>  fell through the cracks?
>
> Thanks.
>
> ********
> I attempted to write test code for AddPixelAccessor, but am getting compile
> errors:
> typedef itk::AddPixelAccessor<float> AddAccessorType;
> itkAddPixelAccesor.h: No such file or directory
>
> I made a copy of itkAddPixelAccesor.h (itkTestAddPixelAccessor.h), and
> received the following error:
> error: expected initializer before'<' token
> which usually means the header wasn't included...
>
> I moved #include "itkTestAddPixelAccessor.h" to the top of my include list
> and got the following error:
> itkTestAddPixelAccessor.h:39: error: invalid function declaration
>
> Consider me perplexed...
>
> On Fri, Dec 10, 2010 at 5:53 AM, Luis Ibanez <luis.ibanez at kitware.com>wrote:
>
>> Hi Robert, David
>>
>>
>> The implementation is correct.
>>
>>
>> You are confusing the role of the Set()  method with
>> the role of the Get() method. One must apply the
>> inverse operation of the other.
>>
>>
>> An ImageAdaptor is intended to present an image
>> as if the image had been processed by a filter.
>>
>> The PixelAccessor for that ImageAdaptor implements
>> the trick of transforming the pixel on the fly.
>>
>> The AddImageAdaptor must present the image A
>> as A+k (where "k" is a constant that it is added to
>> every pixel in A).
>>
>>                           B  =  A + k
>>
>> The addition of K is implemented in the "Get" method.
>>
>> So, if your input image has a pixel with value "7",
>> and "k" has been set to "5",
>>
>> then calling "Get" in that pixel should give you "7+5=12"
>>
>> To be consistent, the "Set" operation must be the
>> inverse of the "Get" operation.
>>
>> So, if you "Set" a pixel to value "12", the "Set" method
>> must store in "A" the value "12-5 = 7".
>>
>> In that way,  if you call "Get" later in that same pixel,
>> you get your "12" back.
>>
>>
>>   Regards,
>>
>>
>>      Luis
>>
>>
>> ---------------------------------------------
>> On Thu, Dec 9, 2010 at 4:33 PM, robert tamburo <robert.tamburo at gmail.com>
>> wrote:
>> > I'm confused with the set function of AddPixelAccessor. It subtracts a
>> value
>> > from the input rather than adding it.
>> > Relevant code:
>> > inline void Set( InternalType & output, const ExternalType & input )
>> const
>> >     { output = static_cast<InternalType>( input - m_Value ); }
>> > Shouldn't it add m_Value to the input? Or is there something else going
>> on?
>> > -Robert
>> >
>> > _____________________________________
>> > Powered by www.kitware.com
>> >
>> > Visit other Kitware open-source projects at
>> > http://www.kitware.com/opensource/opensource.html
>> >
>> > Kitware offers ITK Training Courses, for more information visit:
>> > http://www.kitware.com/products/protraining.html
>> >
>> > Please keep messages on-topic and check the ITK FAQ at:
>> > http://www.itk.org/Wiki/ITK_FAQ
>> >
>> > Follow this link to subscribe/unsubscribe:
>> > http://www.itk.org/mailman/listinfo/insight-users
>> >
>> >
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20101210/781261bc/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.cxx
Type: application/octet-stream
Size: 2535 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20101210/781261bc/attachment.obj>


More information about the Insight-users mailing list