compute gradient image