The previous point about checking the return value of malloc is absolutely correct. Much of programming is about handling error conditions properly.
What are the values in image..image, and exactly what result in meanarray are you expecting to see?
Have you tried checking the algorithm in a simple testbed, e.g.
for (int i=2; i<8; i++)
(there may be errors in that; I just typed it straight in without testing).
I would expect meanarray to contain 4, in this case (2+4+8+1+9=24; 24/5=4).