Normalizing from [0.5 - 1] to [0 - 1]

前端 未结 6 1562
自闭症患者
自闭症患者 2021-01-30 02:45

I\'m kind of stuck here, I guess it\'s a bit of a brain teaser. If I have numbers in the range between 0.5 to 1 how can I normalize it to be between 0 to 1?

Thanks for a

6条回答
  •  孤独总比滥情好
    2021-01-30 03:15

    Lazyweb answer: To convert a value x from [minimum..maximum] to [floor..ceil]:

    General case:

    normalized_x = ((ceil - floor) * (x - minimum))/(maximum - minimum) + floor
    

    To normalize to [0..255]:

    normalized_x = (255 * (x - minimum))/(maximum - minimum)
    

    To normalize to [0..1]:

    normalized_x = (x - minimum)/(maximum - minimum)
    

提交回复
热议问题