I have an image with uneven contrast. Now to correct the image, I need a dark frame to remove the noise inherent to the sensor or to the camera itself. How can use the dark frame into the image? I have been searching the net but most of them use photoshop or similar softwares. How can I apply it mathematically? I was thinking of reversing the values of the dark frame (a pixel value of 100 will become 255 - 100 = 455, considering an 8-bit image), and then subtracting it to the image (although I am not sure if I need to subtract or divide it into the image). Is this correct?