A common technique for doing such a thing is called Inpainting . But for this you need a mask of regions that you want to draw. So, suppose we were able to get a good mask and paint over the original image, given the morphological expansion of this mask:


To get this mask, we do not need anything special. Start by binarizing the difference between the original image and the result of media filtering it:

You can remove isolated pixels; attach the pixels representing the stars of your flag by combining dilatation in the horizontal direction, and then with another dilatation with a small square; delete this largest component you just created; and then perform a geodetic dilatation with the result so far against the initial mask. This gives a good mask above.
Now for inpaint there are many algorithms, but one of the simplest of them I found in Fast digital picture should be easy enough to implement. I did not use it, but you could check what results you can get.
EDIT: I missed that you would also like to brighten up the image.
An easy way to brighten up an image without making the brighter areas even brighter is to use the gamma factor <1. Being more specific to your image, you can first apply a relatively large low-pass filter, neutralize it, multiply the original image by it, and then apply gamma coefficient. In this second case, the final image is likely to be darker than the first, so you multiply it by a simple scalar value. Here are the results for these two cases (the left one is gamma 0.6):


If you really want to brighten up the image, you can apply a two-sided filter and split it into two parts:

source share