Java image color scale adjustment and brightness adjustment code example
I don't know much about the content of java image processing, and my words are simple. Please forgive me.
Java to achieve color scale adjustment, that is, adjust the RGB component of the picture, and then you can also adjust the brightness of the picture.
Test code
Color scale adjustment code
Image reading, and storage functions
Share:
The calculation formulas of brightness and contrast are given below
(RGB represents the value of the color component of the original image, nrgb table does not process the value, mbrightness represents the adjusted brightness value, mcontrast represents the adjusted contrast value, and AVG represents the average value of the whole image pixel) brightness: nrgb = RGB + mbrightness contrast: nrgb = (RGB AVG) * (1-percent%) + AVG percent% the value range is (- 1 ~ 1) 0 is the original value, and the contrast formula is also well proved, Expand it nrgb = rgb-rgb * percent% - AVG + AVG * percent% + AVG nrgb = rgb-rgb * percent% + AVG * percent%. For the whole image matrix, the brightness should be kept unchanged, that is, the algebraic sum of the whole matrix should be kept unchanged. AVG = (rgb1 + rgb2 +.... rgbn) / N (1) (nrgb1 + nrgb2 +.... nrgbn) = (rgb1 + rgb2 +... Rgbn) + n * AVG * percent% - (rgb1 + rgb2 +... Rgbn) * percent% (2) replace equation (1) with equation (2)
summary
The above is all about the java image color scale adjustment and brightness adjustment code example in this paper. I hope it will be helpful to you. If there are deficiencies, please leave a message to point out.