each_channel decorator

Stéfan van der Walt stefan at sun.ac.za
Fri Oct 19 16:35:35 EDT 2012


On Wed, Oct 17, 2012 at 6:48 PM, Tony Yu <tsyu80 at gmail.com> wrote:
> I'm not really sure how a utility function would work. Wouldn't you need to
> provide at least 2 utility functions when converting to LAB:
>
>     image, ab = prepare_rgb(image)
>     # ... code to generate `filtered_image` from `image`
>     filtered_image = finalize_rgb(filtered_image, ab)

A utility function would simply take an image and apply the specified
filter to all its layers (which are pre-and post-converted in some
way), e.g.

apply_to_rgb(image, filter)

> Basically, that's all to say that I think a decorator makes a lot more sense
> in this case.

But it does mean introducing a flag.  I'm debating which is clearer
and more explicit:

apply_to_luminance(image, filter)

vs

filter(image, rgb_behavior='luminance')

(with the caveat that rgb_behavior has to be documented in each and
every filter function--and that we have to figure out a way of
preserving signatures and docstrings with decorators)

Stéfan



More information about the scikit-image mailing list