First of all this is not at all the location to ask this question. All function and methods you are using are of numpy.
To answer the question I think it is doing what it seems. It is multiplying img by 0.5 and adding 0.5 to it. I think the purpose is that the data was initially standardized.
Standardization formula : z = (x-mean)/std
So by doing z*std + mean you are basically de-standardizing the data to it’s original form.