Need a Hand with an Algorithm

Kntx

Platinum Member
Dec 11, 2000
2,270
0
71
I'm writing a quick helper function that coverts a JPEG compression level selected by a user [9=no compression, 1=maximum compression] to the value accepted by the function that does the compression [0=no compression, 255=maximum compression]. So anyways you could draw 0-9 on a the x-axis of a graph and 0-255 on the y-axis, then draw the line. So what is the equation of the line?? I feel like a blithering idiot that I don't remember how to do this, so to all you high school math students out there please lend a hand!!

Thanx!
 

Ioo

Member
May 13, 2004
107
0
0
Need more info on the relationship. You need to identify at least two points, if not more in order to calculate the equation. Are you saying the two points would be 9,0 and 1,255 ?

If so, then your equation is something like:

y = (-31.8750)(x - 9)

Slope(m) = (y2 - y1) / (x2 - x1)

line of best fit = (y - y1) = (m(x - x1))

x = user setting
y = compression function value

This assuming a linear relationship.