Calculation of centroid using image dimension,image spacing and image origin.

I have a doubt in calculation of centroid using image dimension,image spacing and image origin. After that I have to place the 3D view in the center and anterior position . The camera should focus on this centroid . I did it but I am not getting proper result. The image is not present in center, anterior position. Can you please help me to solve this problem?.