float * result = new float(width * height * 5);
This allocates one float and direct-initializes it
You wanted float * result = new float[width * height * 5];
Still the same error. What I think is happening it's somehow the variable count value is being set after the array limit (5*width*height).
Edit: I just find the error. It was in the declaration, instead of use newfloat(width * height * 5) I change to newfloat[width * height * 5] and now the code is working.