Skip to content

Instantly share code, notes, and snippets.

@midibyte
Created February 19, 2018 08:11
Show Gist options
  • Save midibyte/57d1be56bcbb2f71a393420f4b4b16b1 to your computer and use it in GitHub Desktop.
Save midibyte/57d1be56bcbb2f71a393420f4b4b16b1 to your computer and use it in GitHub Desktop.
//transforms a range of [iMin, iMax] to [outMin, outMax]
//returns the transformed value
int range_transform(int input, int iMax, int iMin, int outMax, int outMin)
{
//transform range for histogram operation
int output = (((input - iMin) * (outMax - outMin)) / (iMax - iMin)) + outMin;
return output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment