Skip to content

Generalized use case architecture #18

@jywarren

Description

@jywarren

The initial demo at https://divy123.github.io/colorimetry/public/ is great. It's specific to the use case at publiclab/image-sequencer#979.

How can we generalize the code? Can we adapt it to run on pH strips?

https://duckduckgo.com/?q=ph+test+strip&atb=v121-6&ia=images&iax=images

image

Here is how pH strip comparisons work manually:

image

Maybe pH is too complex as a next step, since it has 4 patches. What about another test that just accepts a min color and a max color, and provides a linear scale between them. So the parameters could be:

color1 (hex)
color2 (hex)
minValue
maxValue
scale (string, "linear" by default for now, eventually maybe exponential, logarithmic, etc)

These could be passed into a constructor like:

// This outputs an object:
var colorimetry = new Colorimetry(color1, color2, minValue, maxValue, scale)

colorimetry.setupUI(); // generates the demo
var output = colorimetry.getValue(color3); // give it a hex value

Something like this for a very basic color comparison?

The initial demo as built would be more like:

colorimetry.compareColors(averageColor1, averageColor2);

Maybe it would need to be compartmentalized somehow, like we load an image into a generic object like:

var image = new ColorimetryImage('url'); // this loads the image into an internal sequencer
var region1 = image.getAverage(x1, y1, h1, w1);
var region2 = image.getAverage(x2, y2, h2, w2);
colorimetry.compareColors(averageColor1, averageColor2);

Or would the all be part of the same object?

I'm just brainstorming a good general-purpose architecture here. What do you think, @Divy123 ? Can this accommodate the original use case, but make it more generalizable to different kinds of colorimetry?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions