Added support for NChannelImage and ExtendToNChannel


Sorry for all the previous open/close pull requests. This is the only merge to look at.

* import numbergen: fixed. It was there for a param, but then I moved that
to RGBImage. If I move colorspaces + RGBImage to imagen it will be used,
anyway.

* patterngenerator "hacky" way to access "generator": I think the problem
is not anymore with the automatic advancing, rather to access the real
"generator" (eg, an NChannelImage embedded within a Selector), in order to
access its "channel_data" ?

* pattern_sampler:  in the original code Chris had a new class extending
ImageSampler but only setting different default parameters. I've removed
the Class and replicated the same behavior using that line. The default
size_normalization was "original" in image.py.   (PS that code snippet is
not my code, anyway; the param in NChannelImage is:

    pattern_sampler = param.ClassSelector(class_=ImageSampler,
        default=PatternSampler(size_normalization='fit_shortest'))
)

* caching is different, because during processing get_image() is called
many times (one for each channel, to perform normal image generation
operations), and would involve reloading the image every time. Checking for
the last filename loaded avoids reloading and only returns the existent,
pre-loaded data.

* Ok for comments, docs and existing commented code!

* Exception on output functions: yes that's an error. Before it was an
assert to make sure that output_fns was indeed EQUAL to zero. I'm not sure
why, it was left from Chris' code. I think that any output function would
just be applied to each channel if they were allowed to be set, anyway.


* As for the last one, which part? The "correlate"?

G





On Fri, Jul 11, 2014 at 10:58 AM, James A. Bednar <notifications@github.com>
wrote:

> In imagen/patterngenerator.py:
>
> > +    ways, ExtendToNChannel will synthesize the channels from the traditional
> > +    single channel generator.
> > +
> > +    After finding or synthesizing the channels, they are
> > +    scaled according to relative_channel_strengths.
> > +    """
> > +
> > +    generator = param.ClassSelector(class_=PatternGenerator,default=Constant(),doc="""
> > +                      PatternGenerator to be converted to N-Channels.""")
> > +
> > +    channel_factors = param.Dynamic(default=[1.,1.,1],doc="""
> > +                      Channel scaling factors. The length of this list sets the number of channels to be
> > +                      created, unless the input_generator is alreay NChannel (in which case the number of
> > +                      its channels is used).""")
> > +
> > +    correlate = param.Parameter(default=None)
>
> This needs documenting, as the code for it below looks very obscure. It
> might not make sense here, and perhaps could move to RGBImage where it
> might be motivated better; but it could stay here if you could imagine some
> possible way this might make sense to do for n-channel images in general.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/ioam/imagen/pull/29/files#r14813905>.
>