A defendant against whom a judgment is rendered for land may, at any time before execution, present a petition to the court rendering the judgment, stating that he, or those under whom he claims, while holding the premises under a color of title believed to be good, have made permanent improvements thereon, and praying that he may be allowed for the improvements, over and above the value of the use and occupation of the land. The court may, if satisfied of the probable truth of the allegation, suspend the execution of the judgment and impanel a jury to assess the damages of the plaintiff and the allowance to the defendant for the improvements. In any such action this inquiry and assessment may be made upon the trial of the cause.
N.C. Gen. Stat. § 1-340