Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

influx contrast control #10

Open
adcxyz opened this issue May 31, 2019 · 1 comment
Open

influx contrast control #10

adcxyz opened this issue May 31, 2019 · 1 comment

Comments

@adcxyz
Copy link
Member

adcxyz commented May 31, 2019

// from @telephon email:

what about controlling the contrast of the influence? Contrast zero would be like zoom = 0, contrast 1 would be only influence the strongest two (explicitly not going down to one, for keeping with authoritarian holistic principles). One may still want to have zoom as well, and combine the two.

  • contrast 0.0 = grey is all influences scaled to 0.5 * zoom.
  • contrast 0.5 = normal, all influences as the weights say - this is what zoom 0.0-1.0 already does
  • contrast 1.0 = b/w, means the high weights remain, and the low weights are suppressed by scaling down to 0
    (like black&white contrast by keeping the top values fixed, and scaling pixels below it darker, clipping at 0=black )
// orig julian example for contrast
(
a = { 1.0.rand2 } ! 8;

f = { |x, contrast, minItems = 2|
	var y = (x - contrast);
	var minval = y.copy.sort.clipAt(minItems);
	y.collect { |x| x.max(0) }.normalize(0, y.maxItem + contrast)
};

[0, 0.2, 0.5, 0.8, 1].collect { |c| f.(a, c) }.plot("contrasts [0, 0.2, 0.5, 0.8, 1]")
)

/* half-solution for 0-1 range 
maximum abs value always remains where it is,
the other values are pushed toward zero
- at contrast 0, leave everything untouched [should be 0.5]
- at contrast 1, the top n minItems remain active, all others 0
- [ range 0-0.5 of proposal not done yet]
*/

// use bipolar values for 8 weights, as in influx
a = { 1.0.rand2 } ! 8;
a.postln.plot("orig");
(
// top value remains where it is
// minimum 2 elements remain active:
// minimum of 3 input elements needed ...
// contrast 0 leaves all values untouched,
f = { |x, contrast = 1, minItems = 2|
	var absvals = x.abs;
	var sortedabsvals = absvals.copy.sort { arg a, b; a > b };
	var maxabs = sortedabsvals[0];
	var minabs = sortedabsvals[minItems];
	absvals.collect { |xval, i| xval.linlin(minabs * contrast, maxabs, 0, maxabs) * x[i].sign };
};
f.value(a, 1.0).plot;
)
// different contrast values with minItems 2
[0, 0.2, 0.5, 0.8, 1].collect { |c| f.(a, c, 2) }.plot("contrasts [0, 0.2, 0.5, 0.8, 1]", 400@400)

// different contrast values with minItems 1
[0, 0.2, 0.5, 0.8, 1].collect { |c| f.(a, c, 1) }.plot("contrasts [0, 0.2, 0.5, 0.8, 1]", 400@400)

// different contrast values with minItems 3
[0, 0.2, 0.5, 0.8, 1].collect { |c| f.(a, c, 3) }.plot("contrasts [0, 0.2, 0.5, 0.8, 1]", 400@400)
@telephon
Copy link

yes, that is what I meant. Very nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants