grain: prevent crash on very small images