Archive: getspec() Pixel Values


21st October 2002 16:51 UTC

getspec() Pixel Values
Is there any way I can assign individual colors to specific value ranges returned by getspec? Like make all values below a certain threshold dark blue, the values in a range above that lighter blue, and the strongest values really light blue or white?

I want to apply colors along the lines of Nullsoft Tiny Fullscreen - Voiceprint. I've fooled around with the red, green, blue values and gotten a smooth color shift, but it is the color is not tied to the strength of a given point in the sample.

Here's my code, and I'm attaching a screenshot of what I have.

Init:
..... t=-1; n=1024; p=2/1024;
Frame:
..... t=if(equal(t,1),-1,t+p);
Point:
..... x=t;
..... y=-i;
..... col=getspec(i/1.37,0,1);
..... red=col; green=col*col; blue=col*i*2;

Thanks,
python_boot


21st October 2002 18:26 UTC

You're doing the right thing. The only thing that seems odd is using 'i' in your color code. 'i' is not related to the getspec value. Just play around some more. Try something like:


col=sqrt(getspec(i*.5,0,1));
blue=-cos(col*3.14)*.5+.5;
green=sqr(col)*3-1;
red=col*2-1;

19th November 2002 12:20 UTC

Is there any way I can assign individual colors to specific value ranges returned by getspec? Like make all values below a certain threshold dark blue

Yep, use an ABOVE() or BELOW() test inside an IF like this:

blue=IF( BELOW(col,lowthreshold) ,0.3,0.6);

Then you can do more IF's like this...

blue=IF( BELOW(col,highthreshold) ,blue,1.0);

If col small then the first IF gives you dark blue, otherwise it sets it to medium blue. If col is big then the second test changes it to bright blue, but if col is medium then the second IF says blue = blue which leaves it unchanged. You can set as many ranges as you like by adding more IF's.

Then you use the same method to set red and again to set green.


19th November 2002 17:40 UTC

I think he's looking for a smooth scaling, which would not be achieved with various IF statements. You could also try built-in chroming (I love chroming :D ):

a=1-a; v=getspec(i/2,0.03,0);
x=i*2-1; y=-if(a,v,0)+0.5;
col=(1-max(v,1-v))*2; col2=(1-max(col,1-col))*2;
red=col; blue=col2; green=(1-max(col2,1-col2))*2;


20th November 2002 05:23 UTC

You release what chroming means (in terms of an action), don't you?


20th November 2002 09:12 UTC

Nice SSC there Atero. YOu truly are the master of experimentation. :)


20th November 2002 18:33 UTC

...whosajiggawhaaa? That was just something absolutely random...

'Chroming' aka 'solarizing' is the process of making bright pixels dark, and medium-brightness pixels bright. Imagine an area with a white point in the middle, then darkening going ******d. Viewed from the 'side' it would look like this (where higher=brighter):
./\
/..\

We want to make it look like this:
/\/\
Basically that means any values that are above 0.5 need to be inverted. To do that, we need to take the minimum value of both the original and it's inverted value, so any pixels equal to 0.5 stay the same, pixels below 0.5 stay the same (because their inverted value is greater than their original), and pixels above 0.5 get inverted (because their inverted value is less than their original). However, the end result has values only between 0 and 0.5, so we need to double any of the values so it doesn't look muddy.
BTW, the code I used doesn't work quite as efficiently, I was thinking of effect-list chroming where you don't get to use minimum blend. Here's the better code:

color=min(color,1-color)*2;


<edit> oops, i suck at doing the php-quotes thing...oh well, i'll just use courier...</edit>


21st November 2002 07:45 UTC

Chrome Effect List:


EL (replace|replace) {
--EL (replace|maximum) {
----Trans/Invert
--}
--Trans/Invert
--Trans/FastBrightness
}

21st November 2002 14:12 UTC

thanks, zevensoft, i like that solution, it gave a better effect than the normal solution