bug fix for a crash when input image is small
Merge pull request #3464 from asuwend1:master