This is called flat frame calibration, basically all cameras sold today will have that auto applied to your raw data even. I had to implement it here for processing raws from a very old camera:
https://blog.maxg.io/reverse-engineering-the-sinar-ia-raw-fi...