Image-sequencer: Non-expanding, fully opaque meta modules

Created on 4 Aug 2018  ยท  16Comments  ยท  Source: publiclab/image-sequencer

The new meta modules is very powerful! You can select one like NDVI-Colormap, and it expands to:

https://publiclab.github.io/image-sequencer/examples/#steps=ndvi(filter:red),colormap(colormap:default)

But, right now, if you want to use a meta module like NDVI-Colormap, you can't just use it in a string like:

https://publiclab.github.io/image-sequencer/examples/#steps=ndvi-colormap

Module NDVI-Colormap not found.

A modification of meta-modules would be great, where:

  1. they are, to all external appearances, just normal modules that don't expand
  2. they contain other modules, but 'secretly' -- i.e. they run a mini-sequencer inside themselves, so they simply accept an incoming image, and produce an output image, and act in every way like a normal module
  3. they would remain shown as a single step, permanently

Then you could modify the internals of a meta module -- say, to optimize it -- and nobody would ever know!

@tech4GT this may be too much to accomplish before the end of SoC, but I'm interested to hear your thoughts!

enhancement new-feature project

All 16 comments

GitMate.io thinks the contributor most likely able to help you is @tech4GT.

Possibly related issues are https://github.com/publiclab/image-sequencer/issues/200 ("Meta" modules -- modules made of other sequences of modules), https://github.com/publiclab/image-sequencer/issues/108 (Math Module), https://github.com/publiclab/image-sequencer/issues/5 (image cropping module), https://github.com/publiclab/image-sequencer/issues/112 (Scale module), and https://github.com/publiclab/image-sequencer/issues/205 (add "drag to crop" UI feature to Crop module).

GitMate.io thinks the contributor most likely able to help you is @tech4GT.

Possibly related issues are https://github.com/publiclab/image-sequencer/issues/200 ("Meta" modules -- modules made of other sequences of modules), https://github.com/publiclab/image-sequencer/issues/108 (Math Module), https://github.com/publiclab/image-sequencer/issues/5 (image cropping module), https://github.com/publiclab/image-sequencer/issues/112 (Scale module), and https://github.com/publiclab/image-sequencer/issues/205 (add "drag to crop" UI feature to Crop module).

@jywarren this is a very interesting idea and yes I don't think we can do this before the end of soc but I will surely work on this afterwards.
One good thing is that our architecture is perfect and all we need to do in order to achieve this is change the expand steps function.

This will be very interesting to implement

agreed, very interesting! And that's great to hear. Think of all the
excellent architectural choices we made earlier in the year that will allow
us to do this! ๐Ÿ‘๐Ÿ‘๐Ÿ‘

On Sat, Aug 4, 2018 at 12:51 PM Varun Gupta notifications@github.com
wrote:

This will be very interesting to implement

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/image-sequencer/issues/315#issuecomment-410462473,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABfJwMoSgszC_JuzEpKHDWrr66cSW35ks5uNdDpgaJpZM4VvDx0
.

I would like to give this issue a try. Can I work on this issue?

this one is a deep one! But @tech4gt has said he thinks it will be possible
with relatively minimal changes. Perhaps he can guide a bit! But YES this
would be amazing!

On Mon, Oct 1, 2018 at 10:45 AM Mridul97 notifications@github.com wrote:

I would like to give this issue a try. Can I work on this issue?

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/image-sequencer/issues/315#issuecomment-425934214,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABfJ7QhcBD7Rnjyn26uKswZxisQiK9dks5ugipsgaJpZM4VvDx0
.

Actually I've been working on this one already. I hope you don't mind @Mridul97

No, not at all!

Thanks!

Hi @tech4GT would you mind sharing any work you've done so far in a PR, or maybe outlining a couple steps towards this goal? I'd love to see progress made on it and if we could do it in parts, even better!

For example, would you consider simply building a module which starts a unique separate instance of ImageSequencer inside itself, passes in a string, and then replies with the output?

@jywarren Sure, I'll open a PR today!

To make creating these new meta-modules easier, we may be able to create a generator for these, which is to say, a way to automate the creation of opaque meta modules given:

  1. a JSON object or string of steps
  2. a function which maps the outer module options to the options objects of the internal steps (or falling back to the defaults if mapping is not provided)
  3. a set of overriding defaults for internal steps (which could be done via the mapping function too)

This could take the form:

module.exports = require('generateMetaModule')(function mapOptions(options) {

  var defaults = require('./../../util/getDefaults.js')(require('./info.json')); // standard defaults fetch

  options.x = options.x || defaults.x;
  options.y = options.y || defaults.y;
  options.colormap = options.colormap || defaults.colormap;
  options.h = options.h || defaults.h;

  // map above defaults into internal steps options:
  return [
    { 'name': 'gradient', 'options': {} },
    { 'name': 'colormap', 'options': { colormap: options.colormap } },
    { 'name': 'crop', 'options': { 'y': 0, 'h': options.h } },
    { 'name': 'overlay', 'options': { 'x': options.x, 'y': options.y, 'offset': -4 } }
  ];
});

@jywarren Let us first finalize the structure of the meta module itself, after that I'll integrate it into createMetaModule function! We can use a flag like options.opaque.
This way we can use all the earlier meta-module work we did, since all that will be changing is the internal structure of the meta-module but the api layer can stay as it is!! This will need minimal code change!! Super exciting!! :tada:

So I was able to figure out 2 ways in which circular dependencies can occur

  1. Dynamically loading a module, we can check for it while loading it
  2. From the source code, this though rare can occur due to a programming error so let's make a test for this.

I will add to this list if I am able to think of more. Thoughts?
cc @publiclab/is-reviewers

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Divy123 picture Divy123  ยท  5Comments

jywarren picture jywarren  ยท  4Comments

jywarren picture jywarren  ยท  5Comments

jywarren picture jywarren  ยท  5Comments

harshkhandeparkar picture harshkhandeparkar  ยท  4Comments