in reply to Image processing

I'd look at the color transformation methods available in Imager, as documented in Imager::Transformations. Most likely, something like the following should work:

$new = $img->convert(matrix=>[ [ $sf ] ])

... assuming you have a grayscale image and I interpret the transformation matrix correctly.