Added proper calculation for pixel weight