- AVS Troubleshooting
- Integers?
Archive: Integers?
UIUC85
24th October 2003 18:27 UTC
Integers?
Is there a way to convert numbers to integers in AVS? I was thinking about making a preset using contour maps of multivariable functions and since the mod command converts to integer before I want it to I was just gonna create my own mod but I cant figure out a way to convert a number to an integer. Is it it possible to return just the integer value of a number??
UnConeD
24th October 2003 18:58 UTC
I use var|0.
UIUC85
24th October 2003 19:29 UTC
Does that only work on the new version of AVS because it doesn't seem to work on the older one I'm running. I always get zero for the return on that.
edit:
Oh... hmm 0|var works though... That's wierd.
edit:
crap that rounds it though...
UnConeD
24th October 2003 21:22 UTC
Binary operators were broken up till AVS2.7, they simply rounded the second argument to int. Using 0|var should work on both versions.
Not sure what you mean by 'crap that rounds it', but if you want to floor/ceil a number, just subtract/add 0.5 before rounding.
UIUC85
25th October 2003 08:47 UTC
Ok here's the idea. I wanna use multivariable functions to create contour maps for presets. So the idea is to set an increment value that defines the spacing between each level. So it would take value%inc to get the remainder. If the remainder is small than the bias value it would consider that value part of a curve and color it white. If the value was above the bias value it would remain black. I can get it to work great when I program it but I can't seem to get it to work in AVS. I think I'm just going to multiply the value of the function and increment by 100, take the mod, then both back down again.
UnConeD
25th October 2003 14:55 UTC
I still don't quite get what you want to do. What do you mean with a contour map? Scopes? Colormap tricks?
You seem to explain everything except the essential :weird:.
UIUC85
25th October 2003 18:43 UTC
Contour map? Level curves? That's what it's called. Have you ever seen a topographic map where it has lines that signify different heights? Just google it or something...
Nic01
25th October 2003 20:50 UTC
Eh?
And how exactly are you using integers for contourmapping?
UnConeD
25th October 2003 20:52 UTC
Exactly what Nic asked. I understand what a contourmap is, but you didn't specify how you want to do it in AVS.
UIUC85
25th October 2003 21:33 UTC
f(x,y)%inc to get the remainder of the value of the function divided by the value that defines the difference between each level. Then I setup a bias value. If the remainder is lower than the bias value then it is on the curve.
Basically it tests each value of the function and sees whether it is close enough to one of the curves. If it is, it colors that spot. Get it?
UnConeD
25th October 2003 22:47 UTC
Argh, so HOW are you drawing it? Your method would require a per-pixel evaluating gridscope and that'd be much too slow I think.
Attached is a very fast and simple contour preset. Change the 9 in the convo to an 8 to get iso-lines only. And here's a kernel for fatter lines:
-1
-1 -2 -1
-1 -2 17 -2 -1
-1 -2 -1
-1
IMO this approach is much more flexible than yours, and much faster in AVS. You could also use a colormap with a banded gradient, but that would give isolines of varying width depending on the gradient of the surface.
UIUC85
25th October 2003 23:49 UTC
I had worked with the DM to do do the same sort of deal, but at the moment I was just playing around with the movement fuction. I've never really played around with the convolution filter so quite frankly I have no idea what any of those numbers mean. I am quite impressed with your preset though. Mind explaining how the convultion filter works?
Nic01
26th October 2003 01:53 UTC
...
Alright, firstly, it takes 9 times the original spot and -1 parts of the parts around it - If it's, say, a plain white surface, all cells will turn out 1 (/1), thus giving you a plain white surface.
On color changes, the edge of the brighter color gets brighter since the darker front will result in less subtraction - brightening the edge. On the flipside, this occurs the other direction - the brighter sight results in more subtraction, darkening the edge.
Get the idea? good.
UIUC85
26th October 2003 01:18 UTC
Ok how about just explaining exactly what the numbers mean mathematically? What does the filter due?
UnConeD
26th October 2003 10:25 UTC
The 7x7 grid is called the convolution-kernel and represents weights assigned to a pixel and its surrounding pixels.
Per pixel, convolution will multiply each constant by the appropriate pixel's color, sum the result, divide and put it back.
The filter above is a simple edge-detection filter (take the difference between 'current pixel x 8' and its eight surrounding values).
A blur is any sort of average of pixels:
1
1 4 1
1
div: 8, bias: 0
embossing
-1 -1 0
-1 1 1
0 1 1
div: 1, bias: 0
For speed reasons, you should try to use a power of two as divider.
In fact this is identical to a 'custom filter' in Photoshop or Paint Shop Pro.
S-uper_T-oast
26th October 2003 21:58 UTC
Thanks for explaing that UnConeD!
dirkdeftly
27th October 2003 23:18 UTC
so...can someone explain to me how x|0 rounds x to the nearest integer? afaik the "old" b0rk3d bitwise operators just chopped off the mantissa....
UnConeD
28th October 2003 00:59 UTC
Atero:
Using 0|var should work on both versions.
The old b0rked operators just cast the right-hand value to int, though with some minor integer fuzzyness (e.g. negative numbers). The new b0rked operators should work as expected.
dirkdeftly
28th October 2003 02:15 UTC
that still doesn't explain how x|0 rounds x to the nearest integer...
fsk
28th October 2003 12:11 UTC
Yup Id wanna know also:). What the hell does | do anyway?
UnConeD
28th October 2003 12:15 UTC
From the help:
|
converts two values to integer, returns bitwise OR of both values
example: var=var2|31;
Or'ing with 0 has no effect, so it does nothing but cast to int.
Deamon
28th October 2003 21:39 UTC
AVS 2.7: floor(value) and ceil(value) work. You might want to use that.
(Read the expression help)
dirkdeftly
29th October 2003 03:12 UTC
arg. forgot those had to cast to int first. but doesn't...that...truncate? to round don't you have to add .5 and cast to int?
UnConeD
29th October 2003 19:01 UTC
That's something you can answer for yourself in 1 minute.