Results 1 to 5 of 5

Math Help - Changing the range of numbers...

  1. #1
    Junior Member
    Joined
    Apr 2010
    Posts
    43

    Changing the range of numbers...

    I am trying to write a program that compares two images. That info is not too important.
    What is important is, that once I ratio the images, I get values starting from decimal numbers (like .0001) to possibly very large numbers (like 10..20..30.....100) depending on what two images I am ratioing.
    The problem is that I am working in GIMP, and image values go from 0 to 255. So anything tiny is getting set to 0.
    Is there some sort of algorithm that will scale my ratio results to these 0-255 values? So lets say I have values between .0001 (lets say, make this value arbitrarily 'a') to 20 ('b'). How can I scale the .0001 to correspond to zero ('x'), the 20 to correspond to 255('y'), and anything in between to scale accordingly? So transform a->x, b->y for arbitrary values of a and b.
    Thanks!
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor
    Joined
    Oct 2009
    Posts
    5,417
    Thanks
    718

    Re: Changing the range of numbers...

    \frac{x-a}{b-a}\cdot255

    One way to derive this formula is as follows. A linear function of x has the form ux+v for some constants u, v. Therefore, we form a system of equations

    ua+v=0
    ub+v=255

    and solve it to find u and v in terms of a and b.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Junior Member
    Joined
    Apr 2010
    Posts
    43

    Re: Changing the range of numbers...

    I apologize if I'm being really slow with this.

    I found u and v:
    u=-255/(a-b)
    v=255a/(a-b)

    How do you get ?

    Thanks!
    Follow Math Help Forum on Facebook and Google+

  4. #4
    MHF Contributor
    Joined
    Oct 2009
    Posts
    5,417
    Thanks
    718

    Re: Changing the range of numbers...

    ux+v=\frac{-255}{a-b}x+\frac{255a}{a-b}=\frac{255}{b-a}x-\frac{255a}{b-a}=\frac{x-a}{b-a}\cdot255
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4

    Re: Changing the range of numbers...

    Quote Originally Posted by cp05 View Post
    I am trying to write a program that compares two images. That info is not too important.
    What is important is, that once I ratio the images, I get values starting from decimal numbers (like .0001) to possibly very large numbers (like 10..20..30.....100) depending on what two images I am ratioing.
    The problem is that I am working in GIMP, and image values go from 0 to 255. So anything tiny is getting set to 0.
    Is there some sort of algorithm that will scale my ratio results to these 0-255 values? So lets say I have values between .0001 (lets say, make this value arbitrarily 'a') to 20 ('b'). How can I scale the .0001 to correspond to zero ('x'), the 20 to correspond to 255('y'), and anything in between to scale accordingly? So transform a->x, b->y for arbitrary values of a and b.
    Thanks!
    Try plotting the logs (base 10 is probably better than natural logs here) of the ratios (add a constant to make most of them all positive and truncate below to a minimum of 0)

    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Condensing a Range of numbers.
    Posted in the Math Software Forum
    Replies: 15
    Last Post: June 15th 2011, 04:52 AM
  2. Replies: 2
    Last Post: April 16th 2010, 03:28 AM
  3. Changing the subject
    Posted in the Pre-Calculus Forum
    Replies: 2
    Last Post: January 14th 2009, 12:19 PM
  4. range, inter-quartile range
    Posted in the Statistics Forum
    Replies: 1
    Last Post: June 19th 2006, 05:06 AM

Search Tags


/mathhelpforum @mathhelpforum