1. A method for weighted encoding of image data, comprising: applying, using a transforming device, a non-linear transformation function to said image data such that selected areas of said image data where increased precision is desired are encoded with an increased bit depth, wherein the step of applying the non-linear transformation function further comprising: arranging pixel information into groups according to bit depths of the pixels of said image data; determining respective gains for said groups, wherein said respective gains are dependent upon a respective number of pixels in said groups; and determining said transformation function based upon said respective gains.