The invention discloses a nonlinear 
underwater image 
gain algorithm for hyperbolic tangent deformation function transformation. The problems of obvious 
noise pollution, 
low contrast ratio, low brightness, low saturation, color 
distortion and the like of 
underwater optical images due to 
water transparency, light and the like can be obviously improved through 
algorithm transformation of the invention. Firstly, an 
underwater grating image file is read as matrix data, three 
layers of matrix data of RGB three channels are extracted respectively, a hyperbolic tangent deformation-based function with an expansion coefficient k is constructed, the 
gain degree and the key 
gain color 
gradation range can be controlled through the appropriate expansion coefficient k, and a hyperbolic tangent deformation function is constructed; the function is used to carry out gain transformation on three 
layers of matrix data of three channels of RGB, and then the three color channels are merged and converted into a new image. The underwater 
optical image is processed through the 
algorithm, the contrast and brightness of the underwater image are improved, important color 
gradation is reasonably redistributed, and the dark area and the color 
gradation are improved while detail information of the image is reserved and even enhanced.