I don't know if a variable that acts as a counter has an associated error. I don't see it as a measured quantity so I think that it has no error.
The problem is this: you have an image of a star and you want to measure its flux (along with the error in your measurement)
My question: do k and i (see below) have an error?
This is some pseudocode describing my solution:
flux, e_flux = 0
sky, e_sky = 0
k,i = 0
Draw circle around star
for pixel in circle:
flux = flux + pixel.counts
e_flux = e_flux + sqrt(pixel.counts)
k = k + 1
for pixel around star:
sky = sky + pixel.counts
e_sky = e_sky + sqrt(pixel.counts)
i = i + 1
sky = sky/i
flux = flux - (sky * k)
I think of k and i as known quantities of pixels. Of course, the measurement of a number of pixels representing the star has a certain error, but since we are approximating the star with a circle at the beginning, is that error encompassed within the approximation of the star? (so k and i are known without uncertainty)
If the count is not always the same, there is an associated error (in the sense of uncertainty, not of mistake).