[Insight-developers] ImageRegionConstIterator operator*
Luis Ibanez
luis . ibanez at kitware . com
Wed, 25 Jun 2003 11:47:58 -0400
Hi Yarden
I agree with you in that it is nice to have consistency
with the notation used for iterators in other libraries
(especially in STL).
However the operator* has the limitation of not allowing
the use of PixelAccessors and hence making impossible to
use ImageAdaptors.
ImageAdaptors are a powerful mechanism for saving memory
consumption in pixel-wise operations. What they do is to
compute pixel values on the fly. Instead of requiring a
filter to compute the whole image before it is passed to
the next filter.
Trivial operations, like negating an image, take advantage
of ImageAdaptors for saving memory. Casting can also be
done with ImageAdaptors instead of using the CastImageFilter.
The limitation of the operator* is that you are forced
to return something like a (PixelType &) which can be
used indiscriminately for doing Get() and Set(). PixelAccessor
however, require to build a temporary type on the fly, so
it is not possible to return a reference to this temporary
type.
Note that if you implement the operator*, it should call
the method "Value()" instead of "Get()". Value() is the
method that give access through a reference, but in the process
it sacrifies the support for PixelAccessors and ImageAdaptors.
---
Could you give us an example of a situation in which
you need to access an ImageIterator from outside ITK ?
In principle you should be able to wrap the filters as
full entities without needing to use ImageIterators.
Maybe there is a better way of configuring the communication
between ITK and SCIRun.
Please let us know some details of what you are doing,
Thanks
Luis
----------------------
Yarden Livnat wrote:
> Luis,
>
> Iterators should follow a certain conventions such as providing
> ++, and * (dereferencing) operators. It's true that as long as one
> work only within the realm of ITK get() is fine, it is not a standard
> way. Once you start working with external code you start to appreciate
> consistency. For example, we can not use ITK iterator for SCIRun code
> which assume it can dereference an iterator (as in STL) in order to get
> to the object. Of cause one can (and we did) derive a new iterator from
> the ITK iterator and added the operator*() which in turn calls .get() but
> it will be cleaner in general if the dereferencing will be part of ITK
> iterators.
>
> does it make sense ?
>
> Yarden
>
> On Wednesday, June 25, 2003, at 09:15 AM, Luis Ibanez wrote:
>
>>
>> Hi Darby,
>>
>> Is there any reason for not using the
>> current "Get()" method in your code ?
>>
>>
>> Luis
>>
>>
>> ------------------------
>> Darby J Van Uitert wrote:
>>
>>> Can I add the operator* to the ImageRegionConstIterator class?
>>> -darby j
>>> ---------------------------
>>> Darby J Van Uitert
>>> SCI Institute
>>> University of Utah
>>> Email: darbyb at cs . utah . edu
>>> Phone: 801.585.1869
>>> ---------------------------
>>> _______________________________________________
>>> Insight-developers mailing list
>>> Insight-developers at itk . org
>>> http://www . itk . org/mailman/listinfo/insight-developers
>>
>>
>>
>>
>> _______________________________________________
>> Insight-developers mailing list
>> Insight-developers at itk . org
>> http://www . itk . org/mailman/listinfo/insight-developers
>>
>
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk . org
> http://www . itk . org/mailman/listinfo/insight-developers
>