When you asked a related question:
How to solve this " index was outside the bounds of the array." error ?[
^] this morning, I told you to use the debugger.
It's the only tool that can tell you what is wrong: this depends on the data in your image and we do not have access to it.
So put a breakpoint on the first line of that method, and start working your way through it, looking at what is going on - it's the only way you are going to solve this!