What is the gain of a telescope? What is the gain of a telescope? How would I go about calculating the gain from a flatfield image?
Gain in electronics can have different meanings:

Gain is a measure of the ability of a [...] [device] to increase the power or amplitude of a signal from the input to the output port. [...] The term gain alone is ambiguous, and can refer to the ratio of output to input voltage (voltage gain), current (current gain) or electric power (power gain).

For optics, I found the light-gathering power the most appropriate measure, which relates the apparture of the telescope with the one of the human eye:

The light-gathering power of an optical telescope, also referred to as light grasp or aperture gain, is the ability of a telescope to collect a lot more light than the human eye. Its light-gathering power is probably its most important feature. [...]
The gathering power $P$ compared against a human eye is the squared result of the division of the aperture $D$ over the observer's pupil diameter $D_{p}$ [...] An example gathering power of [a telescope with] [...] $254\,{\rm mm}$ [aparture] compared to an adult pupil diameter being $7 \, {\rm mm}$ is given by:
$$P = \left(\frac {D}{D_{p}}\right)^2 = \left(\frac {254}{7}\right)^2 \approx 1316.7$$

Edit: After the question changed slightly, I guess I should add a bit on &quot;how to calculate gain from an image&quot;: Gain requires always two measurements, e.g. the image from your telescope and a base of comparison, e.g. the human eye, that's why I found the aperature-based-gain definition appealing.
If you have a datafile with intensities from your telescope - basically an image in grayscales depicting the spatial light intensity distribution - you would have to compile an image of the same area of the sky which serves you as a base of comparison.