fixed type casting for pixel to int