[Insight-users] AddPixelAccessor set function confusion

Luis Ibanez luis.ibanez at kitware.com
Fri Dec 10 05:53:08 EST 2010


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
>
>


More information about the Insight-users mailing list