# Fast Document Enhancement

I followed Dropbox's blog - Fast Document Rectification and Enhancement

To enhancement image, I need solve this formula

J(x,y) = gain(x,y) * I(x,y) + offset(x,y)

Where J is image after enhancement and I is input image. Thank to Royi's answer from this question, i understand how to calculate image J and image I.

How can i calculate gain and offset ?

I tried calculate 2 image I and 2 image J with different size to calculate gain and offset but it still does't work.

Any suggestions would be amazing.

Many thanks.