implemented handling of invalid pixels; if pixel is not valid it is set to NaN in test