Skip to content

Instantly share code, notes, and snippets.

@smithdanielle
Last active August 29, 2015 14:09
Show Gist options
  • Save smithdanielle/808ac27e4381af590ce5 to your computer and use it in GitHub Desktop.
Save smithdanielle/808ac27e4381af590ce5 to your computer and use it in GitHub Desktop.
MATLAB function for normalising an image matrix between [X;Y]
function normalised = normaliseXY(array, x, y)
% Normalize to [0, 1]:
m = min(array(:));
range = max(array(:)) - m;
array = (array - m) ./ range;
% Then scale to [x,y]:
rangeXY = y - x;
normalised = (array*rangeXY) + x;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment