Check whether index is inside image borders for dti
Merge branch 'bug-18361-check-inside-image'