Allocate arrays for cost, fill pixel cost array