Made main the real main, fixed image to use 1D array linearly indexed