Solved by samarendra109 in post #2 
              
              
                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. 
Stan…