I do not know, which of the variables is "your image". That is is "binary" does not concern the problem.
Because roi is used with indices 1 to 4 only, but the error message mentions 8 as limit, the problem is the size of bh. This means, that at least one of the elements of:
is larger than 8, but bh has 8 rows only.
The forum cannot guess how to fix this based on the posted code.