added debug output with number of black pixels