Stores in correct indices in imgIndices.