FUNCTION SCALE_IMAGE, IMAGE, X, Y ;- Create scaled image with specified histogram ;- X is an array of input values ;- Y is an array of specified output values ;- Create output array dims = size(image, /dimensions) nx = dims[0] ny = dims[1] scaled = bytarr(nx, ny) ;- Scale the image for index = 0, n_elements(x) - 2 do begin x1 = x[index] x2 = x[index + 1] y1 = y[index] y2 = y[index + 1] m = (y2 - y1) / float((x2 - x1)) b = y2 - (m * x2) mask = (image ge x1) and (image lt x2) scaled = scaled + mask * byte(m * image + b) endfor ;- Scale the pixels greater than the maximum value mask = image ge x2 scaled = scaled + (mask * 255B) ;- Return the result return, scaled END